Skip to content

Commit

Permalink
Refs #110, implemented NoDisplay and Hidden desktop entry keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
tvrzna committed Jun 11, 2024
1 parent 02d0acd commit 965d751
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions res/emptty.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
desktopLang = "LANG"
desktopLoginShell = "LOGINSHELL"
desktopNames = "DESKTOPNAMES"
desktopNoDisplay = "NODISPLAY"
desktopHidden = "HIDDEN"

constEnvXorg = "xorg"
constEnvWayland = "wayland"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 965d751

Please sign in to comment.