Skip to content

Commit

Permalink
Fixed #119, added auto_selection config option to autoselect first …
Browse files Browse the repository at this point in the history
…desktop, if only one is available.
  • Loading branch information
tvrzna committed Jul 22, 2024
1 parent 97afc22 commit 551b16a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ Path to directory, where Wayland sessions' desktop files are stored. Default val
`SELECT_LAST_USER`
Enables funtionality of saving last successfully logged in user for next login. Possible values are "false", "per-tty" or "global". Default value is false.

`AUTO_SELECTION`
If set to "true" and only one desktop is available, it automatically select that desktop. Possible values are "true" or "false". Default value is false.

#### Dynamic MOTD
If `DYNAMIC_MOTD` is set to `true`, this file exists and is executable for its owner, the result is printed as your own MOTD. Be very careful with this script!

Expand Down
5 changes: 4 additions & 1 deletion res/emptty.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH EMPTTY 1 "June 2024" "emptty 0.12.1" emptty
.TH EMPTTY 1 "July 2024" "emptty 0.12.1" emptty

.SH NAME
emptty \- Dead simple CLI Display Manager on TTY
Expand Down Expand Up @@ -175,6 +175,9 @@ Path to directory, where Wayland sessions' desktop files are stored. Default val
.IP SELECT_LAST_USER
Enables funtionality of saving last successfully logged in user for next login. Possible values are "false", "per-tty" or "global". Default value is false.

.IP AUTO_SELECTION
If set to "true" and only one desktop is available, it automatically select that desktop. Possible values are "true" or "false". Default value is false.

.SH DYNAMIC MOTD
Optional file stored by default as /etc/emptty/motd-gen.sh. Could be overridden.

Expand Down
3 changes: 2 additions & 1 deletion res/testing/conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ HIDE_ENTER_LOGIN=true
ALWAYS_DBUS_LAUNCH=true
XORG_SESSIONS_PATH=/dev/null
WAYLAND_SESSIONS_PATH=/dev/zero
SELECT_LAST_USER=per-tty
SELECT_LAST_USER=per-tty
AUTO_SELECTION=true
1 change: 1 addition & 0 deletions src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type config struct {
IdentifyEnvs bool `config:"IDENTIFY_ENVS" parser:"ParseBool" default:"false"`
HideEnterLogin bool `config:"HIDE_ENTER_LOGIN" parser:"ParseBool" default:"false"`
HideEnterPassword bool `config:"HIDE_ENTER_PASSWORD" parser:"ParseBool" default:"false"`
AutoSelection bool `config:"AUTO_SELECTION" parser:"ParseBool" default:"false"`
DefaultSessionEnv enEnvironment `config:"DEFAULT_SESSION_ENV" parser:"ParseEnv" default:""`
AutologinSessionEnv enEnvironment `config:"AUTOLOGIN_SESSION_ENV" parser:"ParseEnv" default:""`
Logging enLogging `config:"LOGGING" parser:"ParseLogging" default:"rotate"`
Expand Down
4 changes: 4 additions & 0 deletions src/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func TestLoadConfig(t *testing.T) {
if conf.SelectLastUser != PerTty {
t.Error("TestLoadConfig: SELECT_LAST_USER value is not correct")
}

if !conf.AutoSelection {
t.Error("TestLoadConfig: AUTO_SELECTION value is not correct")
}
}

func TestLangLoadConfig(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions src/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func selectDesktop(usr *sysuser, conf *config, d *desktop) (*desktop, *desktop)
}
}

// If there is just one desktop and selection is set to Auto, select first desktop
if len(desktops) == 1 && d != nil && d.selection == SelectionAuto {
// If there is just one desktop and AutoSelection is set or selection is set to Auto, select first desktop
if len(desktops) == 1 && (conf.AutoSelection || (d != nil && d.selection == SelectionAuto)) {
return desktops[0], desktops[lastDesktop]
}

Expand Down

0 comments on commit 551b16a

Please sign in to comment.