From 19ee0fc14ea3517193d8ed1ca6391036f615c5b5 Mon Sep 17 00:00:00 2001 From: lightly-toasted Date: Tue, 26 Aug 2025 16:44:11 +0900 Subject: [PATCH] refactor: migrate powermenu.sh to writeShellScriptBin --- home/toast/bin/powermenu.sh | 16 ---------------- home/toast/home.nix | 5 +---- home/toast/modules/hyprland.nix | 2 +- home/toast/modules/powermenu.nix | 24 ++++++++++++++++++++++++ hosts/nixos/modules/services/default.nix | 1 + hosts/nixos/modules/services/restic.nix | 2 +- 6 files changed, 28 insertions(+), 22 deletions(-) delete mode 100755 home/toast/bin/powermenu.sh create mode 100755 home/toast/modules/powermenu.nix diff --git a/home/toast/bin/powermenu.sh b/home/toast/bin/powermenu.sh deleted file mode 100755 index e027b1a..0000000 --- a/home/toast/bin/powermenu.sh +++ /dev/null @@ -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 diff --git a/home/toast/home.nix b/home/toast/home.nix index dd7c9af..9fb4c5f 100644 --- a/home/toast/home.nix +++ b/home/toast/home.nix @@ -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"; -} \ No newline at end of file +} diff --git a/home/toast/modules/hyprland.nix b/home/toast/modules/hyprland.nix index 09e698a..02e2291 100644 --- a/home/toast/modules/hyprland.nix +++ b/home/toast/modules/hyprland.nix @@ -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" diff --git a/home/toast/modules/powermenu.nix b/home/toast/modules/powermenu.nix new file mode 100755 index 0000000..e26249b --- /dev/null +++ b/home/toast/modules/powermenu.nix @@ -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 + '') + ]; +} + diff --git a/hosts/nixos/modules/services/default.nix b/hosts/nixos/modules/services/default.nix index a293f2c..856bd8d 100644 --- a/hosts/nixos/modules/services/default.nix +++ b/hosts/nixos/modules/services/default.nix @@ -6,5 +6,6 @@ ./greetd.nix ./tailscale.nix ./flatpak.nix + ./restic.nix ]; } diff --git a/hosts/nixos/modules/services/restic.nix b/hosts/nixos/modules/services/restic.nix index 5b93211..99ac410 100644 --- a/hosts/nixos/modules/services/restic.nix +++ b/hosts/nixos/modules/services/restic.nix @@ -12,7 +12,7 @@ "/data/Backup" "/home/toast/workspace" ]; - repository = "rclone:gdrive/restic"; + repository = "rclone:gdrive:restic"; rcloneConfigFile = config.sops.secrets."restic/rclone-config".path; pruneOpts = [ "--keep-daily 7"