add systemctl fallbacks for non-systemd systems

This commit is contained in:
end-4 2024-03-19 17:46:32 +07:00
parent 1d1d9dc0c8
commit 239e545ecb
5 changed files with 17 additions and 17 deletions

View file

@ -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);

View file

@ -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({

View file

@ -1,5 +1,5 @@
$lock_cmd = pidof hyprlock || hyprlock
$suspend_cmd = systemctl suspend
$suspend_cmd = systemctl suspend || loginctl suspend
general {
lock_cmd = $lock_cmd

View file

@ -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

View file

@ -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"
}