From a3c1cb1ff5a83c0b8d94933b75702d550f2cc8a3 Mon Sep 17 00:00:00 2001 From: Andrej Benz Date: Mon, 10 Feb 2025 15:04:40 +0100 Subject: [PATCH] applications: properly parse NotShowIn and OnlyShowIn per action --- internal/modules/applications.go | 28 ++++++++++++++++++++-------- internal/util/misc.go | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/internal/modules/applications.go b/internal/modules/applications.go index b9f8aac..6b576da 100644 --- a/internal/modules/applications.go +++ b/internal/modules/applications.go @@ -355,20 +355,26 @@ func (a *Applications) parse() []util.Entry { if strings.HasPrefix(line, "OnlyShowIn=") { onlyshowin := strings.Split(strings.TrimSpace(strings.TrimPrefix(line, "OnlyShowIn=")), ";") - if slices.Contains(onlyshowin, desktop) { - continue + hide := !slices.Contains(onlyshowin, desktop) + + if isAction { + app.Actions[len(app.Actions)-1].Hide = hide + } else { + app.Generic.Hide = hide } - done[info.Name()] = struct{}{} - return nil + continue } if strings.HasPrefix(line, "NotShowIn=") { notshowin := strings.Split(strings.TrimSpace(strings.TrimPrefix(line, "NotShowIn=")), ";") - if slices.Contains(notshowin, desktop) { - done[info.Name()] = struct{}{} - return nil + hide := slices.Contains(notshowin, desktop) + + if isAction { + app.Actions[len(app.Actions)-1].Hide = hide + } else { + app.Generic.Hide = hide } continue @@ -526,6 +532,10 @@ func (a *Applications) parse() []util.Entry { } for k := range app.Actions { + if app.Actions[k].Hide { + continue + } + sub := app.Generic.Label if a.config.ShowGeneric && app.Generic.Sub != "" && !a.config.Actions.HideCategory { @@ -564,7 +574,9 @@ func (a *Applications) parse() []util.Entry { for _, v := range apps { if a.config.ShowGeneric || !a.config.Actions.Enabled || len(v.Actions) == 0 { - entries = append(entries, v.Generic) + if !v.Generic.Hide { + entries = append(entries, v.Generic) + } } if a.config.Actions.Enabled { diff --git a/internal/util/misc.go b/internal/util/misc.go index b9052f0..f83c338 100644 --- a/internal/util/misc.go +++ b/internal/util/misc.go @@ -50,6 +50,7 @@ type Entry struct { DaysSinceUsed int `mapstructure:"-"` File string `mapstructure:"-"` HashIdent string `mapstructure:"-"` + Hide bool `mapstructure:"-"` History bool `mapstructure:"-"` IgnoreUnprefixed bool `mapstructure:"-"` IsAction bool `mapstructure:"-"`