Skip to content

Commit 8641dc5

Browse files
authored
fix: non-GNOME systemd fallbacks for session scripts (#147)
1 parent fb8d5f5 commit 8641dc5

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

scripts/session/session-logout.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
#!/bin/sh
1+
#!/usr/bin/sh
22
#
33
# name: Log Out
44
# icon: system-log-out
55
# description: Log out to the login screen
66
# keywords: log out logout
77

8-
gnome-session-quit --logout
8+
set -eu
9+
10+
is_gnome() {
11+
command -v dbus-send >/dev/null && \
12+
command -v gnome-session-quit >/dev/null && \
13+
dbus-send --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.freedesktop.DBus.Properties.Get string:org.gnome.Shell string:ShellVersion >/dev/null 2>&1
14+
}
15+
16+
if is_gnome; then
17+
gnome-session-quit --logout
18+
elif command -v loginctl >/dev/null; then
19+
loginctl terminate-user "${USER}"
20+
fi

scripts/session/session-reboot.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
#!/bin/sh
1+
#!/usr/bin/sh
22
#
33
# name: Restart
44
# icon: system-restart
55
# description: Reboot the system
66
# keywords: power reboot restart
77

8-
gnome-session-quit --reboot
8+
set -eu
9+
10+
is_gnome() {
11+
command -v dbus-send >/dev/null && \
12+
command -v gnome-session-quit >/dev/null && \
13+
dbus-send --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.freedesktop.DBus.Properties.Get string:org.gnome.Shell string:ShellVersion >/dev/null 2>&1
14+
}
15+
16+
if is_gnome; then
17+
gnome-session-quit --reboot
18+
elif command -v systemctl >/dev/null; then
19+
systemctl reboot
20+
fi
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
#!/bin/sh
1+
#!/usr/bin/sh
22
#
33
# name: Power off
44
# icon: system-shutdown
55
# description: Shut down the system
66
# keywords: power off shutdown poweroff
77

8-
gnome-session-quit --power-off
8+
set -eu
9+
10+
is_gnome() {
11+
command -v dbus-send >/dev/null && \
12+
command -v gnome-session-quit >/dev/null && \
13+
dbus-send --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.freedesktop.DBus.Properties.Get string:org.gnome.Shell string:ShellVersion >/dev/null 2>&1
14+
}
15+
16+
if is_gnome; then
17+
gnome-session-quit --power-off
18+
elif command -v systemctl >/dev/null; then
19+
systemctl poweroff
20+
fi

scripts/session/session-suspend.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#!/bin/sh
1+
#!/usr/bin/sh
22
#
33
# name: Suspend
44
# icon: system-suspend
55
# description: Suspend the system
66
# keywords: suspend sleep
77

8+
set -eu
9+
810
systemctl suspend

0 commit comments

Comments
 (0)