fix: non-GNOME systemd fallbacks for session scripts (#147)

This commit is contained in:
Ron Waldon-Howe 2022-12-03 08:18:41 +11:00 committed by GitHub
parent fb8d5f50eb
commit 8641dc5b3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 7 deletions

View file

@ -1,8 +1,20 @@
#!/bin/sh
#!/usr/bin/sh
#
# name: Log Out
# icon: system-log-out
# description: Log out to the login screen
# keywords: log out logout
gnome-session-quit --logout
set -eu
is_gnome() {
command -v dbus-send >/dev/null && \
command -v gnome-session-quit >/dev/null && \
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
}
if is_gnome; then
gnome-session-quit --logout
elif command -v loginctl >/dev/null; then
loginctl terminate-user "${USER}"
fi

View file

@ -1,8 +1,20 @@
#!/bin/sh
#!/usr/bin/sh
#
# name: Restart
# icon: system-restart
# description: Reboot the system
# keywords: power reboot restart
gnome-session-quit --reboot
set -eu
is_gnome() {
command -v dbus-send >/dev/null && \
command -v gnome-session-quit >/dev/null && \
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
}
if is_gnome; then
gnome-session-quit --reboot
elif command -v systemctl >/dev/null; then
systemctl reboot
fi

View file

@ -1,8 +1,20 @@
#!/bin/sh
#!/usr/bin/sh
#
# name: Power off
# icon: system-shutdown
# description: Shut down the system
# keywords: power off shutdown poweroff
gnome-session-quit --power-off
set -eu
is_gnome() {
command -v dbus-send >/dev/null && \
command -v gnome-session-quit >/dev/null && \
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
}
if is_gnome; then
gnome-session-quit --power-off
elif command -v systemctl >/dev/null; then
systemctl poweroff
fi

View file

@ -1,8 +1,10 @@
#!/bin/sh
#!/usr/bin/sh
#
# name: Suspend
# icon: system-suspend
# description: Suspend the system
# keywords: suspend sleep
set -eu
systemctl suspend