OVERHEAD

Run cage foot without VTs

Shoe-in Linux

So, remember last time when I said I haven’t even thought about compiling the kernel without VTs?

Well, in this blog post

I was still too lazy.

However, even without compiling out virtual terminals, it’s still possible to run programs without a dependency on VTs, and recently, I figured out how to do so with my cage foot service.

Improved service(s)

New name

From the same person who brought us the name “null favicon”, reese provided a much better name for the cage foot service:

a foot cage? i think the word for that is “shoe” 🙃

reese

Brand new shoes

Contents of the /usr/lib/systemd/system/shoe.service systemd service file.

# Shoe is a system service for executing `foot` in `cage` with auto-login as the
# user configured here.

[Unit]
Description=Cage Wayland compositor running Foot.
# Make sure we are started after logins are permitted. If Plymouth is used, we 
# want to start when it is on its way out.
After=systemd-user-sessions.service plymouth-quit-wait.service
# Since we are part of the graphical session, make sure we are started before it
# is complete.
Before=graphical.target shutdown.target initrd-switch-root.target
# systemd-logind doesn't work due to PAM issues(?), so pull in seatd instead.
Wants=seatd.service
After=seatd.service
# Fallback to `getty.service` if Shoe fails after multiple restarts.
OnFailure=getty@tty1.service

[Service]
Type=idle
# Set variable to software rendering to skip attempting other renderers.
Environment="WLR_RENDERER=pixman"
# Set the `XKB_DEFAULT_*` variables in `/etc/environment`.
ExecStart=/usr/bin/cage -- /usr/bin/foot
# Cleanly terminate `cage` with `SIGHUP`, otherwise it coredumps.
KillSignal=SIGHUP
# If there really aren't VTs, Shoe is the only way to interact, so always restart.
Restart=always
# Stop the service if many restarts happen in quick succession.
StartLimitBurst=3
User=rescue
# For accessing `/run/seatd.sock`, as provided by `seatd.service`.
Group=seat
# Log this user with utmp, letting it show up with commands `w` and
# `who`. This is needed since we replace (a)getty.
UtmpIdentifier=shoe
UtmpMode=user

# Set up a full (custom) user session for the user.
## This is the name of a `/etc/pam.d/` file.
PAMName=login

[Install]
WantedBy=graphical.target

Additionally, to make Shoe actually independent of VTs, you’ll need to create a drop-in file for the seatd.service service:

Contents of the /usr/lib/systemd/system/seatd.service.d/novt.conf systemd service drop-in file

[Service]
Environment="SEATD_VTBOUND=0"

And finally, here’s a quick list of the changes not explained by the file’s comments:

  1. All the TTY-related options are removed. Figures.
    • Notice the missing @ character in the Shoe service’s filename, since there’s nothing for Shoe to be bound to anymore.
  2. Shoe no longer conflicts, nor is set to come after, getty@.service. Since Shoe doesn’t depend on VTs, Getty is free to run in the background without causing any problems.
    • The OnFailure option remains for if Shoe fails, though this line should be removed if you’re running a system which really doesn’t have any VTs.
    • You may still want to disable the getty@.service services to save resources, though this step is optional as explained above.
  3. The Type was changed from simple to idle. The only difference between these options is that idle will wait for active jobs to be dispatched, which in theory is more robust (getty@.service also uses this service type).
  4. The PAMName was changed from cage to login, as the existing /etc/pam.d/login PAM config works perfectly fine and saves creating a separate PAM config for Shoe.

Footnotes (get it?)

  • If you run the chvt N command, nothing visually will change on screen, however, you can run systemctl status getty@N.service to see that Getty has been started on that TTY, and that Shoe is simply displaying on top of everything.
  • As you may expect, you won’t be able to see kernel panic messages in Foot. The original Reddit posts (see the previous blog post) mention using socat and other tools & techniques for maybe getting this working, however, I’m still too lazy.