Greetd

From ArchWiki
Jump to navigation Jump to search

greetd is a minimal, agnostic and flexible login manager daemon which doesn't make assumptions about what the user wants to launch, should it be console-based or graphical. Any script or program which can be started from the console may be launched by greetd, which makes it particularly suitable for Wayland compositors. It can also launch a greeter to start user sessions, like any other display manager.

Installation

Install the greetdAUR or greetd-gitAUR packages.

Configuration

The default configuration file is /etc/greetd/config.toml. PAM-specific options should be set in /etc/pam.d/greetd.

Greeters

In order to allow user sessions to be started, greetd can launch a greeter. Several greeters are available:

By default, greeters are run as the greeter user. This can be changed by editing the user option in the default_session section of the configuration file and replacing another_user with the chosen user:

 ...
 user = "another_user"
 ...

Make sure the ownership of the /etc/greetd directory is set accordingly.

agreety

In order to launch a normal console session with agreety, edit the configuration file as follows:

 ...
 [default_session]
 command = "agreety --cmd $SHELL"
 ...

agreety can launch any arbitrary command once a user logs in. For example, in order to start Sway, replace $SHELL in the example above with sway.

gtkgreet

In order to run, gtkgreet needs a compositor. It is recommended to use Sway, but cage can also be used. Make sure the compositor you would like to use is installed before starting greetd. If you want to use cage, your [default_session] section should be:

 ...
 [default_session]
 command = "cage gtkgreet"
 ...

If you want to use Sway, the greeter must be terminated once the user logs in. For that purpose, a specific configuration file must be created for Sway, for example in /etc/greetd/sway-config, with the following content:

 # `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet.
 exec "gtkgreet -l; swaymsg exit"
 
 bindsym Mod4+shift+e exec swaynag \
 -t warning \
 -m 'What do you want to do?' \
 -b 'Poweroff' 'systemctl poweroff' \
 -b 'Reboot' 'systemctl reboot'
 
 include /etc/sway/config.d/*

Then, gtkgreeter must be set to start Sway with the configuration file above:

 ...
 [default_session]
 command = "sway --config /etc/greetd/sway-config"
 ...

In order to specify which sessions can be started by gtkgreet, list them in /etc/greetd/environments. For example:

 sway
 bash

Instead, you can also invoke gtkgreet with the -c mycommand parameter, replacing mycommand with the desired program (for example, bash or sway) either in /etc/greetd/config.toml, if you use Cage, or in /etc/greetd/sway-config, if you use Sway.

wlgreet

In order for greetd to start wlgreet, follow the steps required to set up gtkgreet with Sway as described above with the following /etc/greetd/sway-config instead:

 exec "wlgreet --command sway; swaymsg exit"
 
 bindsym Mod4+shift+e exec swaynag \
 -t warning \
 -m 'What do you want to do?' \
 -b 'Poweroff' 'systemctl poweroff' \
 -b 'Reboot' 'systemctl reboot'
  
 include /etc/sway/config.d/*

tuigreet

tuigreet does not require any special setup, just refer to it in /etc/greetd/config.toml:

...
[default_session]
command = "tuigreet --cmd sway"
...

See the customization option with tuigreet --help.

Autologin

If you want a user to be logged in automatically, an initial session must be defined in the configuration file:

 [default_session]
 command = "cage gtkgreet"
 
 [initial_session]
 command = "sway"
 user = "myuser"

The command option may contain the name of any executable file. In the example above, Sway will be started by myuser at boot and gtkgreet will be launched after the user logs out.

Starting greetd at boot

Enable greetd.service for greetd to be started at boot.

See also