From 239e545ecb9f0ab1a409329e872fdfc7854f7799 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:46:32 +0700 Subject: [PATCH] add systemctl fallbacks for non-systemd systems --- .config/ags/modules/overview/miscfunctions.js | 6 +++--- .config/ags/modules/session/sessionscreen.js | 12 ++++++------ .config/hypr/hypridle.conf | 2 +- .config/hypr/hyprland/keybinds.conf | 4 ++-- .config/wlogout/layout | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.config/ags/modules/overview/miscfunctions.js b/.config/ags/modules/overview/miscfunctions.js index e13aa2ba..be3ae6c1 100644 --- a/.config/ags/modules/overview/miscfunctions.js +++ b/.config/ags/modules/overview/miscfunctions.js @@ -57,13 +57,13 @@ export function launchCustomCommand(command) { Todo.add(args.slice(1).join(' ')); } else if (args[0] == '>shutdown') { // Shut down - execAsync([`bash`, `-c`, `systemctl poweroff`]).catch(print); + execAsync([`bash`, `-c`, `systemctl poweroff || loginctl poweroff`]).catch(print); } else if (args[0] == '>reboot') { // Reboot - execAsync([`bash`, `-c`, `systemctl reboot`]).catch(print); + execAsync([`bash`, `-c`, `systemctl reboot || loginctl reboot`]).catch(print); } else if (args[0] == '>sleep') { // Sleep - execAsync([`bash`, `-c`, `systemctl suspend`]).catch(print); + execAsync([`bash`, `-c`, `systemctl suspend || loginctl suspend`]).catch(print); } else if (args[0] == '>logout') { // Log out execAsync([`bash`, `-c`, `pkill Hyprland || pkill sway`]).catch(print); diff --git a/.config/ags/modules/session/sessionscreen.js b/.config/ags/modules/session/sessionscreen.js index eb2089c5..e9c0d711 100644 --- a/.config/ags/modules/session/sessionscreen.js +++ b/.config/ags/modules/session/sessionscreen.js @@ -61,13 +61,13 @@ const SessionButton = (name, icon, command, props = {}, colorid = 0) => { export default () => { // lock, logout, sleep - const lockButton = SessionButton('Lock', 'lock', () => { App.closeWindow('session'); execAsync(['loginctl', 'lock-session']) }, {}, 1); - const logoutButton = SessionButton('Logout', 'logout', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'pkill Hyprland || pkill sway']) }, {}, 2); - const sleepButton = SessionButton('Sleep', 'sleep', () => { App.closeWindow('session'); execAsync('systemctl suspend') }, {}, 3); + const lockButton = SessionButton('Lock', 'lock', () => { App.closeWindow('session'); execAsync(['loginctl', 'lock-session']).catch(print) }, {}, 1); + const logoutButton = SessionButton('Logout', 'logout', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'pkill Hyprland || pkill sway || pkill niri || loginctl terminate-user $USER']).catch(print) }, {}, 2); + const sleepButton = SessionButton('Sleep', 'sleep', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'systemctl suspend || loginctl suspend']).catch(print) }, {}, 3); // hibernate, shutdown, reboot - const hibernateButton = SessionButton('Hibernate', 'downloading', () => { App.closeWindow('session'); execAsync('systemctl hibernate') }, {}, 4); - const shutdownButton = SessionButton('Shutdown', 'power_settings_new', () => { App.closeWindow('session'); execAsync('systemctl poweroff') }, {}, 5); - const rebootButton = SessionButton('Reboot', 'restart_alt', () => { App.closeWindow('session'); execAsync('systemctl reboot') }, {}, 6); + const hibernateButton = SessionButton('Hibernate', 'downloading', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'systemctl hibernate || loginctl hibernate']).catch(print) }, {}, 4); + const shutdownButton = SessionButton('Shutdown', 'power_settings_new', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'systemctl poweroff || loginctl poweroff']).catch(print) }, {}, 5); + const rebootButton = SessionButton('Reboot', 'restart_alt', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'systemctl reboot || loginctl reboot']).catch(print) }, {}, 6); const cancelButton = SessionButton('Cancel', 'close', () => App.closeWindow('session'), { className: 'session-button-cancel' }, 7); const sessionDescription = Widget.Box({ diff --git a/.config/hypr/hypridle.conf b/.config/hypr/hypridle.conf index 3efbd108..94976824 100644 --- a/.config/hypr/hypridle.conf +++ b/.config/hypr/hypridle.conf @@ -1,5 +1,5 @@ $lock_cmd = pidof hyprlock || hyprlock -$suspend_cmd = systemctl suspend +$suspend_cmd = systemctl suspend || loginctl suspend general { lock_cmd = $lock_cmd diff --git a/.config/hypr/hyprland/keybinds.conf b/.config/hypr/hyprland/keybinds.conf index 77bf038d..d78fdd08 100644 --- a/.config/hypr/hyprland/keybinds.conf +++ b/.config/hypr/hyprland/keybinds.conf @@ -35,7 +35,7 @@ bind = Super, Q, killactive, bind = Super+Alt, Space, togglefloating, bind = Shift+Super+Alt, Q, exec, hyprctl kill bind = Control+Shift+Alt, Delete, exec, pkill wlogout || wlogout -p layer-shell -bind = Control+Shift+Alt+Super, Delete, exec, systemctl poweroff +bind = Control+Shift+Alt+Super, Delete, exec, systemctl poweroff || loginctl poweroff # Screenshot, Record, OCR, Color picker, Clipboard history bind = Super+Shift+Alt, S, exec, grim -g "$(slurp)" - | swappy -f - @@ -65,7 +65,7 @@ bindl= ,XF86AudioPlay, exec, playerctl play-pause # Lock screen bind = Super, L, exec, loginctl lock-session bind = Super+Shift, L, exec, loginctl lock-session -bindl = Super+Shift, L, exec, sleep 0.1 && systemctl suspend +bindl = Super+Shift, L, exec, sleep 0.1 && systemctl suspend || loginctl suspend # App launcher bind = Control+Super, Slash, exec, pkill anyrun || anyrun diff --git a/.config/wlogout/layout b/.config/wlogout/layout index 6ef1eac6..c31abd94 100644 --- a/.config/wlogout/layout +++ b/.config/wlogout/layout @@ -6,31 +6,31 @@ } { "label" : "hibernate", - "action" : "systemctl hibernate", + "action" : "systemctl hibernate || loginctl hibernate", "text" : "save", "keybind" : "h" } { "label" : "logout", - "action" : "killall Hyprland", + "action" : "pkill Hyprland || pkill sway || pkill niri || loginctl terminate-user $USER", "text" : "logout", "keybind" : "e" } { "label" : "shutdown", - "action" : "systemctl poweroff", + "action" : "systemctl poweroff || loginctl poweroff", "text" : "power_settings_new", "keybind" : "s" } { "label" : "suspend", - "action" : "systemctl suspend", + "action" : "systemctl suspend || loginctl suspend", "text" : "bedtime", "keybind" : "u" } { "label" : "reboot", - "action" : "systemctl reboot", + "action" : "systemctl reboot || loginctl reboot", "text" : "restart_alt", "keybind" : "r" }