Lightdm is too heavy for postmarketOS
Why lightdm should be replaced
In postmarketOS edge, we have experimented with using lightdm-mobile-greeter, and I'm reverting this in !1630 (closed) (see MR for reasoning). Then we will have lightdm with automatic login again.
While this is an improvement over installing a greeter by default, I think we should replace lightdm:
- lightdm + dependencies is 176 MiB (!)
- autologin only works per username, not uid (leading to #820 (closed))
- with lightdm + automatic login, phosh won't display its lockscreen on boot (#811 (closed))
tinydm
While looking for a replacement, I found autologin. It's a nice minimal program that does autologin on TTY, much like we did it with /etc/inittab before using lightdm. But with this, we can do it without hacking into /etc/inittab, and it can easily be manually restarted like any other service.
"autologin" doesn't "manage"/start wayland or X11 sessions directly, so I've written a couple of very short scripts and called them tinydm (to be moved to the pmOS gitlab org, once a bit more polished. I wanted to present these ideas here first and collect feedback).
After some initial testing, I think we should be able to replace lightdm with tinydm, and even resolve the other problems above. With this new stack, I was able to boot into phosh and enable/disable the lockscreen on boot, depending on whether FDE is enabled or not. (I wanted to test plasma-mobile too, but the dependencies appear to be broken right now in edge, I'll look into it.)
Concept:
-
/var/lib/tinydm/default-session.desktop
is a symlink to the wayland/x11 session to be started. -
tinydm.initd
- openrc service file, runs
autologin user tinydm-run-session
- the username should be determined by uid, and the uid provided in a config file that postmarketos-base installs
- essentially we can do
rc-service tinydm restart
then, just as if it was lightdm
- openrc service file, runs
-
tinydm-run-session
- resolves
/var/lib/tinydm/default-session.desktop
- starts the session (wayland or x11 is determined by the resolved path)
- the session is locked or unlocked on start, depending on whether FDE was booted or not
- the idea is, that if you are booting an encrypted installation, you have already typed in the FDE password. You don't need to type in the user password, too.
-
phosh hasit will work differently, see below-L
(locked) and-U
(unlocked) arguments for this, which I've added to a custom wayland-session .desktop file asX-LockedArg
andX-UnlockedArg
. (Could be standardized in the future.)
- resolves
-
tinydm-set-session
is used to update this link- example:
tinydm-set-session /usr/share/wayland-sessions/phosh.desktop
- postmarketos-ui-* packages would have this in their post-install and post-upgrade
- if the symlink exists and points to an existing file, it does not get replaced. A link to this wiki page would be shown, where the user could learn how to replace the tinydm setup with lightm + greeter, so they could switch between the UIs.
- a force flag [-f] would overwrite it in any case
- example:
-
tinydm-unset-session
is used to remove a known outdated link- example:
tinydm-unset-session /usr/share/wayland-sessions-pmos/phosh.desktop
- if the link exists and points to exactly that file, it is removed.
- in any case, exit code is 0
- this can be used, when we ship a custom desktop file for some reason, and later want to remove it in an update, via post-upgrade script.
- example:
tinydm-unset-session /usr/share/wayland-sessions-pmos/phosh.desktop
tinydm-set-session /usr/share/wayland-sessions/phosh.desktop
Install size
$ pmbootstrap zap
$ pmbootstrap chroot
/ # apk add
OK: 9 MiB in 20 packages
/ # apk add lightdm
...
OK: 185 MiB in 112 packages
$ pmbootstrap zap
$ pmbootstrap chroot
/ # apk add
OK: 9 MiB in 20 packages
/ # apk add tinydm
(1/4) Installing linux-pam (1.4.0-r1)
(2/4) Installing autologin (0_git20200406-r0)
(3/4) Installing tinydm-openrc (0_p20201010191555-r0)
(4/4) Installing tinydm (0_p20201010191555-r0)
Executing busybox-1.32.0-r3.trigger
OK: 10 MiB in 24 packages
PoC links
- https://gitlab.com/postmarketOS/tinydm
-
https://gitlab.postmarketos.org/postmarketos/pmaports/-/commits/tinydm
- build latest tinydm with
pmbootstrap build --src=path/to/tinydm tinydm
- build latest tinydm with
Thoughts? :)