Skip to content

Commit

Permalink
applications: properly parse NotShowIn and OnlyShowIn per action
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Feb 10, 2025
1 parent d585315 commit a3c1cb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
28 changes: 20 additions & 8 deletions internal/modules/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/util/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
Expand Down

0 comments on commit a3c1cb1

Please sign in to comment.