From 54553ffae1538d19de680349257d0630b847e60b Mon Sep 17 00:00:00 2001 From: SPFabGerman <42518661+SPFabGerman@users.noreply.github.com> Date: Thu, 9 Jun 2022 21:32:38 +0200 Subject: [PATCH] Added support for Hidden, OnlyShowIn and NotShowIn --- xdgdesktop_parser.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/xdgdesktop_parser.go b/xdgdesktop_parser.go index a305f6b..d70516c 100644 --- a/xdgdesktop_parser.go +++ b/xdgdesktop_parser.go @@ -54,7 +54,34 @@ func parseDesktopEntry(id string, in io.Reader) (entry desktopEntry, err error) case "Terminal": entry.Terminal, _ = strconv.ParseBool(value) case "NoDisplay": - entry.NoDisplay, _ = strconv.ParseBool(value) + if !entry.NoDisplay { + entry.NoDisplay, _ = strconv.ParseBool(value) + } + case "Hidden": + if !entry.NoDisplay { + entry.NoDisplay, _ = strconv.ParseBool(value) + } + case "OnlyShowIn": + if !entry.NoDisplay { + entry.NoDisplay = true + currentDesktop := os.Getenv("XDG_CURRENT_DESKTOP") + if currentDesktop != "" { + for _, ele := range strings.Split(value, ";") { + if ele == currentDesktop && ele != "" { + entry.NoDisplay = false + } + } + } + } + case "NotShowIn": + currentDesktop := os.Getenv("XDG_CURRENT_DESKTOP") + if !entry.NoDisplay && currentDesktop != "" { + for _, ele := range strings.Split(value, ";") { + if ele == currentDesktop && ele != "" { + entry.NoDisplay = true + } + } + } case "Exec": entry.Exec = cleanexec.Replace(value) }