refactor: invoke cosmic-osd in session scripts when available

This commit is contained in:
Ashley Wulber 2025-01-16 15:27:19 -05:00 committed by Michael Murphy
parent c37c2a3c6a
commit cd39e58040
3 changed files with 21 additions and 3 deletions

View file

@ -13,7 +13,13 @@ is_gnome() {
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
is_cosmic() {
command -v cosmic-osd >/dev/null && [ "$XDG_SESSION_DESKTOP" = "COSMIC" ]
}
if is_cosmic; then
cosmic-osd log-out
elif is_gnome; then
gnome-session-quit --logout
elif command -v loginctl >/dev/null; then
loginctl terminate-user "${USER}"

View file

@ -13,7 +13,13 @@ is_gnome() {
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
is_cosmic() {
command -v cosmic-osd >/dev/null && [ "$XDG_SESSION_DESKTOP" = "COSMIC" ]
}
if is_cosmic; then
cosmic-osd restart
elif is_gnome; then
gnome-session-quit --reboot
elif command -v systemctl >/dev/null; then
systemctl reboot

View file

@ -13,7 +13,13 @@ is_gnome() {
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
is_cosmic() {
command -v cosmic-osd >/dev/null && [ "$XDG_SESSION_DESKTOP" = "COSMIC" ]
}
if is_cosmic; then
cosmic-osd shutdown
elif is_gnome; then
gnome-session-quit --power-off
elif command -v systemctl >/dev/null; then
systemctl poweroff