mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
f085384bc7
Sometimes graphical-session.target lingers on after niri quits, leading to services not being started on a quick relogin. To work around this, add and run a systemd target that conflicts with graphical-session.target and forces its shutdown.
48 lines
1.4 KiB
Bash
Executable File
48 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ -n "$SHELL" ] &&
|
|
grep -q "$SHELL" /etc/shells &&
|
|
! (echo "$SHELL" | grep -q "false") &&
|
|
! (echo "$SHELL" | grep -q "nologin"); then
|
|
if [ "$1" != '-l' ]; then
|
|
exec bash -c "exec -l '$SHELL' -c '$0 -l $*'"
|
|
else
|
|
shift
|
|
fi
|
|
fi
|
|
|
|
# Make sure there's no already running session.
|
|
if systemctl --user -q is-active niri.service; then
|
|
echo 'A niri session is already running.'
|
|
exit 1
|
|
fi
|
|
|
|
# Reset failed state of all user units.
|
|
systemctl --user reset-failed
|
|
|
|
# Set the current desktop for xdg-desktop-portal.
|
|
export XDG_CURRENT_DESKTOP=niri
|
|
|
|
# Ensure the session type is set to Wayland for xdg-autostart apps.
|
|
export XDG_SESSION_TYPE=wayland
|
|
|
|
# Import the login manager environment.
|
|
systemctl --user import-environment
|
|
|
|
# DBus activation environment is independent from systemd. While most of
|
|
# dbus-activated services are already using `SystemdService` directive, some
|
|
# still don't and thus we should set the dbus environment with a separate
|
|
# command.
|
|
if hash dbus-update-activation-environment 2>/dev/null; then
|
|
dbus-update-activation-environment --all
|
|
fi
|
|
|
|
# Start niri and wait for it to terminate.
|
|
systemctl --user --wait start niri.service
|
|
|
|
# Force stop of grahical-session.target.
|
|
systemctl --user start --job-mode=replace-irreversibly niri-shutdown.target
|
|
|
|
# Unset environment that we've set.
|
|
systemctl --user unset-environment WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
|