Files
niri/resources/niri-session
T

42 lines
1.2 KiB
Bash
Raw Normal View History

#!/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
2023-08-27 07:37:36 +04:00
# 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
# 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.
2023-08-27 10:27:57 +04:00
systemctl --user --wait start niri.service
2024-06-09 10:50:22 +00:00
# Force stop of graphical-session.target.
2023-11-25 11:01:23 +04:00
systemctl --user start --job-mode=replace-irreversibly niri-shutdown.target
2023-08-27 10:27:57 +04:00
# Unset environment that we've set.
systemctl --user unset-environment WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP NIRI_SOCKET