refactor: migrate powermenu.sh to writeShellScriptBin

This commit is contained in:
lightly-toasted 2025-08-26 16:44:11 +09:00
parent 1f045e291d
commit 19ee0fc14e
6 changed files with 28 additions and 22 deletions

View file

@ -1,16 +0,0 @@
#!/usr/bin/env bash
choice=$(printf """
󰍃 Logout
⏻ Shutdown
 Reboot
 Suspend
 Hibernate
""" | tofi)
case "$choice" in
"󰍃 Logout") uwsm stop ;;
"⏻ Shutdown") systemctl poweroff ;;
" Reboot") systemctl reboot ;;
" Suspend") systemctl suspend ;;
" Hibernate") systemctl hibernate ;;
esac

View file

@ -17,11 +17,8 @@
username = "toast";
homeDirectory = "/home/toast";
stateVersion = "24.11";
file = {
"bin" = { source = ./bin; recursive = true; };
};
};
nixpkgs.config.allowUnfree = true;
systemd.user.startServices = "sd-switch";
}
}

View file

@ -71,7 +71,7 @@
"$mod SHIFT, 0, movetoworkspace, 10"
"$mod SHIFT, S, exec, env HYPRSHOT_DIR=/data/Backup/Screenshots hyprshot -m region"
"$mod SHIFT, E, exec, ~/bin/powermenu.sh"
"$mod SHIFT, E, exec, powermenu"
"$mod, mouse:277, exec, cycle-mouse-action"
", mouse:277, exec, run-mouse-action"

View file

@ -0,0 +1,24 @@
{ pkgs, ... }:
{
home.packages = [
(pkgs.writeShellScriptBin "powermenu" ''
choice=$(printf """
󰍃 Logout
Shutdown
Reboot
Suspend
Hibernate
""" | ${pkgs.tofi}/bin/tofi)
case "$choice" in
"󰍃 Logout") ${pkgs.uwsm}/bin/uwsm stop ;;
" Shutdown") ${pkgs.systemd}/bin/systemctl poweroff ;;
" Reboot") ${pkgs.systemd}/bin/systemctl reboot ;;
" Suspend") ${pkgs.systemd}/bin/systemctl suspend ;;
" Hibernate") ${pkgs.systemd}/bin/systemctl hibernate ;;
esac
'')
];
}