mars

LightDM

Display manager.

The display manager is what runs first when we create a desktop environment. It manages the X servers, and provides a login prompt.

After we enter the credentials in the login prompt, it starts the display environment’s session manager. In our case, that’s xfce4-session.

From their home page - https://github.com/canonical/lightdm

LightDM is a lightweight, cross-desktop display manager. A display manager is a daemon that:

Cross-desktop means that it supports different desktop technologies (X, Wayland, Mir, etc).

The core LightDM project does not provide any greeter with it. Popular options are:

cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.21.3
PRETTY_NAME="Alpine Linux v3.21"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
cat /etc/alpine-release
3.21.3

For Alpine (currently),

Configuration

Per the docs, this is the order in which config is read.

/usr/share/lightdm/lightdm.conf.d/*.conf
/etc/lightdm/lightdm.conf.d/*.conf
/etc/lightdm/lightdm.conf
find /usr/share/lightdm/lightdm.conf.d
find: /usr/share/lightdm/lightdm.conf.d: No such file or directory
find /etc/lightdm/lightdm.conf.d
find: /etc/lightdm/lightdm.conf.d: No such file or directory
wc -l /etc/lightdm/lightdm.conf
163 /etc/lightdm/lightdm.conf
ls /etc/lightdm
keys.conf                 lightdm.conf
lightdm-gtk-greeter.conf  users.conf
cat /etc/lightdm/*.conf | grep -v '^#'
[keyring]
[greeter]
[LightDM]

[Seat:*]

[XDMCPServer]

[VNCServer]
[UserList]
minimum-uid=500
hidden-users=nobody nobody4 noaccess
hidden-shells=/bin/false /usr/sbin/nologin /sbin/nologin

So looks like everything is at the defaults. From the docs

For example, if a sysadmin wanted to override the system configured default session they should make a file /etc/lightdm/lightdm.conf.d/50-myconfig.conf

[Seat:*]
user-session=mysession

Configuration is in keyfile format. For most installations you will want to change the keys in the [Seat:*] section as this applies to all seats on the system (normally just one).

How does lightdm know which greeter to use?

cat /etc/lightdm/lightdm.conf | grep greeters-dir
# greeters-directory = Directory to find greeters
#greeters-directory=$XDG_DATA_DIRS/lightdm/greeters:$XDG_DATA_DIRS/xgreeters
env | grep -e 'XDG'
XDG_CONFIG_DIRS=/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_MENU_PREFIX=xfce-
XDG_CONFIG_HOME=/home/m/.config
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=xfce
XDG_SESSION_TYPE=x11
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/m
XDG_CURRENT_DESKTOP=XFCE
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_CACHE_HOME=/home/m/.cache
XDG_SESSION_CLASS=user
XDG_VTNR=7
XDG_SESSION_ID=c2
XDG_RUNTIME_DIR=/run/user/1000
XDG_DATA_DIRS=/usr/local/share:/usr/share
echo $XDG_DATA_DIRS | tr ':' '\n' | xargs -n 1 -I % ls %/xgreeters
ls: /usr/local/share/xgreeters: No such file or directory
lightdm-gtk-greeter.desktop
apk info --who-owns /usr/share/xgreeters/lightdm-gtk-greeter.desktop
/usr/share/xgreeters/lightdm-gtk-greeter.desktop is owned by lightdm-gtk-greeter-2.0.8-r3

So when I chose Xfce, /usr/sbin/setup-desktop installed both lightdm and lightdm-gtk-greeter, the latter installing this .desktop file which lightdm uses unconfigured (I presume because it’s the only one).

There is also a ~/.dmrc, but from what I gather, lightdm is the one which writes it for us, and going by the creation time, on first login.

cat ~/.dmrc
[Desktop]
Session=xfce

lightdm-gtk-greeter, on success, launches the only xsession it can find

cat /usr/share/xsessions/xfce.desktop | grep -v -e Name -e Comment -e Keywords
[Desktop Entry]
Version=1.0
Exec=startxfce4
Icon=
Type=Application

From Running Xfcedocs.xfce.org:

Running Xfce

apk info --who-owns /usr/share/xsessions/xfce.desktop
/usr/share/xsessions/xfce.desktop is owned by xfce4-session-4.20.2-r0

Once startxfce4 is running, the ball is in Xfce’s court.

dm-tool

dm-tool can be used to communicate with lightdm.

dm-tool
Seat0
  CanSwitch=true
  HasGuestAccount=false
  Session2
    UserName='m'

Autologin

If running in a context with prior authentication, e.g. in a VM, it is convenient to autologin into the sole user account.

As described in the lightdm doc section quoted above,

sysadmins … make a file /etc/lightdm/lightdm.conf.d/50-myconfig.conf

[Seat:*]
user-session=mysession
cat /etc/lightdm/lightdm.conf | grep autologin-user
# autologin-user = User to log in with by default (overrides autologin-guest)
# autologin-user-timeout = Number of seconds to wait before loading default user
#autologin-user=
#autologin-user-timeout=0

install is handy to create the config file, creating the directory and also setting the permissions.

echo | install -D -m 644 /dev/stdin /etc/lightdm/lightdm.conf.d/50-autologin.conf <<EOF
[Seat:*]
autologin-user=$(whoami)
EOF

If something is not working, /var/log/lightdm.