diff --git a/scripts/session/session-logout.sh b/scripts/session/session-logout.sh index 25b1600..bebcfca 100644 --- a/scripts/session/session-logout.sh +++ b/scripts/session/session-logout.sh @@ -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 diff --git a/scripts/session/session-reboot.sh b/scripts/session/session-reboot.sh index c57edd6..125362b 100644 --- a/scripts/session/session-reboot.sh +++ b/scripts/session/session-reboot.sh @@ -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 \ No newline at end of file +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 diff --git a/scripts/session/session-shutdown.sh b/scripts/session/session-shutdown.sh index 4d64e7c..46250ec 100644 --- a/scripts/session/session-shutdown.sh +++ b/scripts/session/session-shutdown.sh @@ -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 diff --git a/scripts/session/session-suspend.sh b/scripts/session/session-suspend.sh index dd0259f..5aeb580 100644 --- a/scripts/session/session-suspend.sh +++ b/scripts/session/session-suspend.sh @@ -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