From 965d751bfc0201d47b86c7a72017fb9e3a2bb7a0 Mon Sep 17 00:00:00 2001 From: Michal Tvrznik Date: Tue, 11 Jun 2024 14:23:56 +0200 Subject: [PATCH] Refs #110, implemented `NoDisplay` and `Hidden` desktop entry keys. --- README.md | 2 ++ res/emptty.1 | 2 ++ src/desktop.go | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bdd7ece..4d51abe 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,8 @@ See [samples](SAMPLES.md#custom-sessions) `DesktopNames` Value passed into `XDG_CURRENT_DESKTOP` variable. +`NoDisplay` / `Hidden` Boolean value, that controls visibility of desktop session. + #### `${HOME}./xinitrc` If config `XINITRC_LAUNCH` is set to true, it enables possibility to use .xinitrc script. See [samples](SAMPLES.md#xinitrc) diff --git a/res/emptty.1 b/res/emptty.1 index 08a5b8e..c4ff7e9 100644 --- a/res/emptty.1 +++ b/res/emptty.1 @@ -237,6 +237,8 @@ Selects, which environment should be defined for following command. Possible val Value passed into .I XDG_CURRENT_DESKTOP variable. +.IP NoDisplay/Hidden +Boolean value, that controls visibility of desktop session. .SH LAST SESSION The last user selection of session is stored into ~/.cache/emptty/last-session diff --git a/src/desktop.go b/src/desktop.go index 066060f..2cae994 100644 --- a/src/desktop.go +++ b/src/desktop.go @@ -20,6 +20,8 @@ const ( desktopLang = "LANG" desktopLoginShell = "LOGINSHELL" desktopNames = "DESKTOPNAMES" + desktopNoDisplay = "NODISPLAY" + desktopHidden = "HIDDEN" constEnvXorg = "xorg" constEnvWayland = "wayland" @@ -91,6 +93,8 @@ type desktop struct { child *desktop loginShell string desktopNames string + noDisplay bool + hidden bool } // Gets exec path from desktop and returns true, if command allows dbus-launch. @@ -258,7 +262,9 @@ func listDesktops(env enEnvironment, paths ...string) []*desktop { err := filepath.Walk(path, func(filePath string, fileInfo os.FileInfo, err error) error { if !fileInfo.IsDir() && strings.HasSuffix(filePath, ".desktop") { d := getDesktop(filePath, env) - result = append(result, d) + if !d.noDisplay && !d.hidden { + result = append(result, d) + } } return nil }) @@ -286,6 +292,10 @@ func getDesktop(path string, env enEnvironment) *desktop { d.env = parseEnv(value, constEnvXorg) case desktopNames: d.desktopNames = value + case desktopNoDisplay: + d.noDisplay = parseBool(value, "false") + case desktopHidden: + d.hidden = parseBool(value, "false") } }) return &d