From 3246abbedf76d4de04fd8678e8d519b51a0ef45d Mon Sep 17 00:00:00 2001 From: Andrej Benz Date: Sun, 14 Jul 2024 16:31:34 +0200 Subject: [PATCH] feat: add 'terminal' to module definition to allow simple external moduels to run in terminal --- config/config.go | 1 + modules/external.go | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 729ee1e..2490f56 100644 --- a/config/config.go +++ b/config/config.go @@ -80,6 +80,7 @@ type Module struct { SpecialLabel string `json:"special_label,omitempty"` History bool `json:"history,omitempty"` SwitcherExclusive bool `json:"switcher_exclusive,omitempty"` + Terminal bool `json:"terminal,omitempty"` } type Search struct { diff --git a/modules/external.go b/modules/external.go index ffa8256..0f627c2 100644 --- a/modules/external.go +++ b/modules/external.go @@ -21,6 +21,7 @@ type External struct { cmd string switcherExclusive bool recalculateScore bool + terminal bool } func (e External) SwitcherExclusive() bool { @@ -37,6 +38,7 @@ func (e External) Setup(cfg *config.Config) Workable { e.switcherExclusive = module.SwitcherExclusive e.src = module.Src e.cmd = module.Cmd + e.terminal = module.Terminal return e } @@ -104,10 +106,11 @@ func (e External) Entries(ctx context.Context, term string) []Entry { } e := Entry{ - Label: unescaped, - Sub: e.ModuleName, - Class: e.ModuleName, - Exec: strings.ReplaceAll(e.cmd, "%RESULT%", txt), + Label: unescaped, + Sub: e.ModuleName, + Class: e.ModuleName, + Terminal: e.terminal, + Exec: strings.ReplaceAll(e.cmd, "%RESULT%", txt), } if !hasExplicitResult {