diff --git a/etc/skel/.config/river/init b/etc/skel/.config/river/init index b2e444c..a07c5f1 100755 --- a/etc/skel/.config/river/init +++ b/etc/skel/.config/river/init @@ -1,5 +1,36 @@ #!/usr/bin/env bash +export XDG_CURRENT_DESKTOP=river +export XDG_SESSION_DESKTOP="${XDG_SESSION_DESKTOP:-river}" +export XDG_SESSION_TYPE=wayland +VARIABLES="DESKTOP_SESSION XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE" +VARIABLES="${VARIABLES} DISPLAY WAYLAND_DISPLAY" +SESSION_TARGET="river-session.target" +SESSION_SHUTDOWN_TARGET="river-session-shutdown.target" + +if hash dbus-update-activation-environment 2>/dev/null; then + # shellcheck disable=SC2086 + dbus-update-activation-environment --systemd ${VARIABLES:- --all} +fi + +# reset failed state of all user units +systemctl --user reset-failed + +# shellcheck disable=SC2086 +systemctl --user import-environment $VARIABLES +systemctl --user start "$SESSION_TARGET" + +# declare cleanup handler and run it on init termination via kill, Ctrl-C or 'riverctl exit' +session_cleanup () { + # stop the session target and unset the variables + systemctl --user start --job-mode=replace-irreversibly "$SESSION_SHUTDOWN_TARGET" + if [ -n "$VARIABLES" ]; then + # shellcheck disable=SC2086 + systemctl --user unset-environment $VARIABLES + fi +} +trap session_cleanup EXIT INT TERM + # Set keyboard layout. See man riverctl # riverctl keyboard-layout -options "grp:caps_toggle" "us,ru" @@ -12,9 +43,6 @@ riverctl spawn "/usr/bin/mate-polkit" # Wallpaper riverctl spawn $HOME/.azotebg -# Waybar -riverctl spawn $HOME/.config/river/waybar.sh - # Include keybindings riverctl spawn $HOME/.config/river/keybindings.sh @@ -37,21 +65,13 @@ riverctl spawn /usr/share/river/scripts/screenshot-notify.sh & disown # Lock screen daemon riverctl spawn $HOME/.config/river/screenlock.sh -# Poweralertd daemon -pkill poweralertd -poweralertd -s -i "line power" & disown - # Set background and border color riverctl background-color 0x002b36 riverctl border-color-focused 0x8aadf4 riverctl border-color-unfocused 0xa5adcb riverctl border-width 2 -# Import environment variables to D-Bus and systemd -VARIABLES="DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE" - -exec systemctl --user import-environment $VARIABLES - -if hash dbus-update-activation-environment 2>/dev/null; then - exec dbus-update-activation-environment --systemd ${VARIABLES:- --all} -fi +# Set the default layout generator to be rivertile and start it. +# River will send the process group of the init executable SIGTERM on exit. +riverctl default-layout rivertile +rivertile -view-padding 6 -outer-padding 6 diff --git a/etc/skel/.config/river/keybindings.sh b/etc/skel/.config/river/keybindings.sh index ccbcc73..966554e 100755 --- a/etc/skel/.config/river/keybindings.sh +++ b/etc/skel/.config/river/keybindings.sh @@ -170,8 +170,3 @@ riverctl float-filter-add app-id "qt6ct" riverctl float-filter-add app-id "pavucontrol" riverctl float-filter-add title "Picture-in-Picture" riverctl float-filter-add title "Firefox — Sharing Indicator" - -# Set the default layout generator to be rivertile and start it. -# River will send the process group of the init executable SIGTERM on exit. -riverctl default-layout rivertile -rivertile -view-padding 6 -outer-padding 6 & diff --git a/etc/skel/.config/river/waybar.sh b/etc/skel/.config/river/waybar.sh deleted file mode 100755 index b598e78..0000000 --- a/etc/skel/.config/river/waybar.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -killall -q waybar -while pgrep -x waybar >/dev/null; do sleep 2s; done -exec waybar & disown -exit diff --git a/usr/lib/systemd/user/river-session-shutdown.target b/usr/lib/systemd/user/river-session-shutdown.target new file mode 100644 index 0000000..d01452e --- /dev/null +++ b/usr/lib/systemd/user/river-session-shutdown.target @@ -0,0 +1,10 @@ +[Unit] +Description=Shutdown running River session +DefaultDependencies=no +StopWhenUnneeded=true + +Conflicts=graphical-session.target graphical-session-pre.target +After=graphical-session.target graphical-session-pre.target + +Conflicts=river-session.target +After=river-session.target diff --git a/usr/lib/systemd/user/river-session.target b/usr/lib/systemd/user/river-session.target new file mode 100644 index 0000000..61ee733 --- /dev/null +++ b/usr/lib/systemd/user/river-session.target @@ -0,0 +1,6 @@ +[Unit] +Description=River session +Documentation=man:systemd.special(7) +BindsTo=graphical-session.target +Wants=graphical-session-pre.target +After=graphical-session-pre.target