river: Change to runit-managed user service

Switching to runit (and turnstiled, which in turn activates user-local
runit service supervision) we can now have river run supervised by our
service manager quite easily.

We make use of this, but have to take care to export the
river-established wayland variables (DISPLAY, WAYLAND_DISPLAY) back into
the user environment for other processes since river will not be the
one responsible for spawning them anymore.

On finishing the service (i.e. exiting the process), we ensure
that the variables get removed from the environment again so it is not
polluted in the future.

Additionally, we load the (default for void runit) 'turnstile-ready'
service which can define core user services that need to exist before
others on login, and the session-local dbus service which river and
other programs will make use of. It is marked as essential with
turnstile-ready.
This commit is contained in:
Marty Oehme 2025-02-24 16:59:02 +01:00
parent ea1bd6c573
commit 7c0bd5738f
Signed by: Marty
GPG key ID: 4E535BC19C61886E
8 changed files with 35 additions and 1 deletions
desktop/.config/river
services/sv
dbus
river
turnstile-ready

View file

@ -1,8 +1,14 @@
#!/usr/bin/env sh
# turnstiled user service setup
if [ -d "$TURNSTILE_ENV_DIR" ]; then
echo "$DISPLAY" >"$TURNSTILE_ENV_DIR/DISPLAY"
echo "$WAYLAND_DISPLAY" >"$TURNSTILE_ENV_DIR/WAYLAND_DISPLAY"
fi
mod="Mod4"
modemod="Mod1"
term=${TERMINAL:-foot}
term=${TERMINAL:-wezterm}
time_to_lockscreen=300
time_to_screendim=600
time_to_suspend=900

2
services/sv/dbus/log/run Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec vlogger -t dbus_user -p daemon

1
services/sv/dbus/run Symbolic link
View file

@ -0,0 +1 @@
/usr/share/examples/turnstile/dbus.run

6
services/sv/river/finish Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
if [ -d "$TURNSTILE_ENV_DIR" ]; then
[ -r "$TURNSTILE_ENV_DIR/DISPLAY" ] && rm "$TURNSTILE_ENV_DIR/DISPLAY"
[ -r "$TURNSTILE_ENV_DIR/WAYLAND_DISPLAY" ] && rm "$TURNSTILE_ENV_DIR/WAYLAND_DISPLAY"
fi

3
services/sv/river/log/run Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env sh
exec vlogger -t river -p daemon

10
services/sv/river/run Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
[ -r ./conf ] && . ./conf
if [ -d "$TURNSTILE_ENV_DIR" ]; then
echo "$HOME/.local/bin:$PATH" > "$TURNSTILE_ENV_DIR/PATH"
fi
exec 2>&1
exec chpst -e "$TURNSTILE_ENV_DIR" river -log-level warning

View file

@ -0,0 +1 @@
core_services="dbus"

View file

@ -0,0 +1,5 @@
#!/bin/sh
[ -r ./conf ] && . ./conf
[ -n "$core_services" ] && SVDIR=".." sv start $core_services
[ -p "/run/turnstiled/1000/ready" ] && printf "/home/marty/.local/state/service/turnstile-ready" > "/run/turnstiled/1000/ready"
exec pause