diff --git a/cmd/version.txt b/cmd/version.txt index 99b953e..ef50561 100644 --- a/cmd/version.txt +++ b/cmd/version.txt @@ -1 +1 @@ -0.8.10-git +0.8.10 diff --git a/internal/config/config.default.json b/internal/config/config.default.json index baaa522..494492a 100644 --- a/internal/config/config.default.json +++ b/internal/config/config.default.json @@ -34,6 +34,7 @@ "show_generic": false }, "calc": { + "require_number": true, "weight": 5, "name": "calc", "icon": "accessories-calculator", diff --git a/internal/config/config.go b/internal/config/config.go index 5441941..80bc891 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -72,6 +72,7 @@ type Builtins struct { type Calc struct { GeneralModule `mapstructure:",squash"` + RequireNumber bool `mapstructure:"require_number"` } type CustomCommands struct { diff --git a/internal/modules/calc.go b/internal/modules/calc.go index 0235b5b..c2e740a 100644 --- a/internal/modules/calc.go +++ b/internal/modules/calc.go @@ -5,14 +5,16 @@ import ( "log" "os/exec" "strings" + "unicode" "github.com/abenz1267/walker/internal/config" "github.com/abenz1267/walker/internal/util" ) type Calc struct { - general config.GeneralModule - hasClip bool + general config.GeneralModule + requireNumber bool + hasClip bool } func (c *Calc) General() *config.GeneralModule { @@ -35,6 +37,7 @@ func (c *Calc) Setup(cfg *config.Config) bool { c.general = cfg.Builtins.Calc.GeneralModule c.general.IsSetup = true + c.requireNumber = cfg.Builtins.Calc.RequireNumber // to update exchange rates cmd := exec.Command("qalc", "-e", "1+1") @@ -46,6 +49,18 @@ func (c *Calc) Setup(cfg *config.Config) bool { func (c *Calc) SetupData(cfg *config.Config, ctx context.Context) {} func (c Calc) Entries(ctx context.Context, term string) []util.Entry { + hasNumber := false + + for _, c := range term { + if unicode.IsDigit(c) { + hasNumber = true + } + } + + if !hasNumber { + return []util.Entry{} + } + entries := []util.Entry{} cmd := exec.Command("qalc", "-t", term)