From d39da7fbfd24e904d7a44ab13d94510df6d91b61 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Thu, 6 Apr 2023 01:27:09 +0530 Subject: [PATCH] move power-menu to the scripts package --- home/scripts.nix | 34 ---------------------------------- packages/default.nix | 2 ++ packages/scripts/default.nix | 16 ++++++++++++++++ packages/scripts/power-menu.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 packages/scripts/default.nix create mode 100644 packages/scripts/power-menu.sh diff --git a/home/scripts.nix b/home/scripts.nix index b199f2e..6723f71 100644 --- a/home/scripts.nix +++ b/home/scripts.nix @@ -27,40 +27,6 @@ in ''; executable = true; }; - "scripts/power_menu.sh" = { - executable = true; - text = '' - #!/bin/sh - - set -eu - - chpower() { - case "$1" in - "") - ;; - Shutdown) - exec systemctl poweroff - ;; - Reboot) - exec systemctl reboot - ;; - Hibernate) - exec systemctl hibernate - ;; - Logout) - swaymsg exit - ;; - *) - ${notify-send} -t 1500 -u low "Invalid Option" - ;; - esac - } - - OPTIONS="Shutdown\nReboot\nHibernate\nLogout" - - chpower "$(printf "%b" "$OPTIONS" | sort | ${dmenu} -p "Power Menu")" - ''; - }; "scripts/volume_up.sh" = let diff --git a/packages/default.nix b/packages/default.nix index 9db905f..85a3065 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -3,6 +3,8 @@ self: super: { catppuccin-wallpapers = super.callPackage ./catppuccin-wallpapers { }; dracula-gtk = super.callPackage ./dracula-gtk { }; newaita-icon-theme = super.callPackage ./newaita-icon-theme { }; + scripts = super.callPackage ./scripts { }; + waybar = super.waybar.overrideAttrs (oldAttrs: { mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; }); diff --git a/packages/scripts/default.nix b/packages/scripts/default.nix new file mode 100644 index 0000000..d43c396 --- /dev/null +++ b/packages/scripts/default.nix @@ -0,0 +1,16 @@ +{ lib, stdenvNoCC, makeWrapperm, libnotify }: +stdenvNoCC.mkDerivation { + pname = "scripts"; + version = "1.0"; + src = ./.; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ ]; + + installPhase = '' + mkdir -p $out/bin + cp power-menu.sh $out/bin/power-menu + chmod +x $out/bin/power-menu + wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [ libnotify ]} + ''; +} diff --git a/packages/scripts/power-menu.sh b/packages/scripts/power-menu.sh new file mode 100644 index 0000000..113f1eb --- /dev/null +++ b/packages/scripts/power-menu.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -eu + +chpower() { + case "$1" in + "") + ;; + Shutdown) + exec systemctl poweroff + ;; + Reboot) + exec systemctl reboot + ;; + Hibernate) + exec systemctl hibernate + ;; + *) + notify-send -t 1500 -u low "Invalid Option" + ;; + esac +} + +OPTIONS="Shutdown\nReboot\nHibernate" + +chpower "$(printf "%b" "$OPTIONS" | sort | ${dmenu} -p "Power Menu")" +