add systemctl fallbacks for non-systemd systems

This commit is contained in:
end-4
2024-03-19 17:46:32 +07:00
parent 17efca69f7
commit fd84ecc86c
5 changed files with 17 additions and 17 deletions
@@ -57,13 +57,13 @@ export function launchCustomCommand(command) {
Todo.add(args.slice(1).join(' ')); Todo.add(args.slice(1).join(' '));
} }
else if (args[0] == '>shutdown') { // Shut down 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 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 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 else if (args[0] == '>logout') { // Log out
execAsync([`bash`, `-c`, `pkill Hyprland || pkill sway`]).catch(print); execAsync([`bash`, `-c`, `pkill Hyprland || pkill sway`]).catch(print);
+6 -6
View File
@@ -61,13 +61,13 @@ const SessionButton = (name, icon, command, props = {}, colorid = 0) => {
export default () => { export default () => {
// lock, logout, sleep // lock, logout, sleep
const lockButton = SessionButton('Lock', 'lock', () => { App.closeWindow('session'); execAsync(['loginctl', 'lock-session']) }, {}, 1); 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']) }, {}, 2); 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('systemctl suspend') }, {}, 3); const sleepButton = SessionButton('Sleep', 'sleep', () => { App.closeWindow('session'); execAsync(['bash', '-c', 'systemctl suspend || loginctl suspend']).catch(print) }, {}, 3);
// hibernate, shutdown, reboot // hibernate, shutdown, reboot
const hibernateButton = SessionButton('Hibernate', 'downloading', () => { App.closeWindow('session'); execAsync('systemctl hibernate') }, {}, 4); 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('systemctl poweroff') }, {}, 5); 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('systemctl reboot') }, {}, 6); 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 cancelButton = SessionButton('Cancel', 'close', () => App.closeWindow('session'), { className: 'session-button-cancel' }, 7);
const sessionDescription = Widget.Box({ const sessionDescription = Widget.Box({
+1 -1
View File
@@ -1,5 +1,5 @@
$lock_cmd = pidof hyprlock || hyprlock $lock_cmd = pidof hyprlock || hyprlock
$suspend_cmd = systemctl suspend $suspend_cmd = systemctl suspend || loginctl suspend
general { general {
lock_cmd = $lock_cmd lock_cmd = $lock_cmd
+2 -2
View File
@@ -35,7 +35,7 @@ bind = Super, Q, killactive,
bind = Super+Alt, Space, togglefloating, bind = Super+Alt, Space, togglefloating,
bind = Shift+Super+Alt, Q, exec, hyprctl kill bind = Shift+Super+Alt, Q, exec, hyprctl kill
bind = Control+Shift+Alt, Delete, exec, pkill wlogout || wlogout -p layer-shell 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 # Screenshot, Record, OCR, Color picker, Clipboard history
bind = Super+Shift+Alt, S, exec, grim -g "$(slurp)" - | swappy -f - bind = Super+Shift+Alt, S, exec, grim -g "$(slurp)" - | swappy -f -
@@ -65,7 +65,7 @@ bindl= ,XF86AudioPlay, exec, playerctl play-pause
# Lock screen # Lock screen
bind = Super, L, exec, loginctl lock-session bind = Super, L, exec, loginctl lock-session
bind = Super+Shift, 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 # App launcher
bind = Control+Super, Slash, exec, pkill anyrun || anyrun bind = Control+Super, Slash, exec, pkill anyrun || anyrun
+5 -5
View File
@@ -6,31 +6,31 @@
} }
{ {
"label" : "hibernate", "label" : "hibernate",
"action" : "systemctl hibernate", "action" : "systemctl hibernate || loginctl hibernate",
"text" : "save", "text" : "save",
"keybind" : "h" "keybind" : "h"
} }
{ {
"label" : "logout", "label" : "logout",
"action" : "killall Hyprland", "action" : "pkill Hyprland || pkill sway || pkill niri || loginctl terminate-user $USER",
"text" : "logout", "text" : "logout",
"keybind" : "e" "keybind" : "e"
} }
{ {
"label" : "shutdown", "label" : "shutdown",
"action" : "systemctl poweroff", "action" : "systemctl poweroff || loginctl poweroff",
"text" : "power_settings_new", "text" : "power_settings_new",
"keybind" : "s" "keybind" : "s"
} }
{ {
"label" : "suspend", "label" : "suspend",
"action" : "systemctl suspend", "action" : "systemctl suspend || loginctl suspend",
"text" : "bedtime", "text" : "bedtime",
"keybind" : "u" "keybind" : "u"
} }
{ {
"label" : "reboot", "label" : "reboot",
"action" : "systemctl reboot", "action" : "systemctl reboot || loginctl reboot",
"text" : "restart_alt", "text" : "restart_alt",
"keybind" : "r" "keybind" : "r"
} }