From 90ab81ddd7b2bfee777c7ce4943c40f739bc2502 Mon Sep 17 00:00:00 2001 From: serenity-F Date: Sat, 16 Nov 2024 22:41:32 +1000 Subject: [PATCH] tidying hypr/scripts --- home/desktop/hypr/scripts/brightness.nix | 36 ------------- home/desktop/hypr/scripts/misc.nix | 68 +++++++++++++++++++++++- home/desktop/hypr/scripts/screenshot.nix | 34 ------------ 3 files changed, 67 insertions(+), 71 deletions(-) delete mode 100644 home/desktop/hypr/scripts/brightness.nix delete mode 100644 home/desktop/hypr/scripts/screenshot.nix diff --git a/home/desktop/hypr/scripts/brightness.nix b/home/desktop/hypr/scripts/brightness.nix deleted file mode 100644 index 236ed59..0000000 --- a/home/desktop/hypr/scripts/brightness.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ pkgs, config, ... }: - -let - homedir = config.home.homeDirectory; - increments = "5"; - - brightness-change = pkgs.writeShellScriptBin "brightness-change" '' - sleep 0.05 - - [[ $1 == "up" ]] && ${pkgs.brightnessctl}/bin/brightnessctl set ${increments}%+ - [[ $1 == "down" ]] && ${pkgs.brightnessctl}/bin/brightnessctl set ${increments}%- - - brightness_level=$(${pkgs.brightnessctl}/bin/brightnessctl get) - - message="󰃠 Brightness: $brightness_level%" - - ${pkgs.libnotify}/bin/notify-send "$message" \ - -h int:value:"$brightness_level" \ - --replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification" - ''; - - brightness-up = pkgs.writeShellScriptBin "brightness-up" '' - brightness-change up ${increments} - ''; - - brightness-down = pkgs.writeShellScriptBin "brightness-down" '' - brightness-change down ${increments} - ''; - -in { - home.packages = with pkgs; [ - brightness-change - brightness-up - brightness-down - ]; -} diff --git a/home/desktop/hypr/scripts/misc.nix b/home/desktop/hypr/scripts/misc.nix index 7b64179..f6f807b 100644 --- a/home/desktop/hypr/scripts/misc.nix +++ b/home/desktop/hypr/scripts/misc.nix @@ -3,6 +3,8 @@ let homedir = config.home.homeDirectory; + increments = "5"; + menu = pkgs.writeShellScriptBin "menu" '' if pgrep wofi; then pkill wofi @@ -19,8 +21,72 @@ let fi ''; + brightness-up = pkgs.writeShellScriptBin "brightness-up" '' + brightness-change up ${increments} + ''; + + brightness-down = pkgs.writeShellScriptBin "brightness-down" '' + brightness-change down ${increments} + ''; + + brightness-change = pkgs.writeShellScriptBin "brightness-change" '' + sleep 0.05 + + [[ $1 == "up" ]] && ${pkgs.brightnessctl}/bin/brightnessctl set ${increments}%+ + [[ $1 == "down" ]] && ${pkgs.brightnessctl}/bin/brightnessctl set ${increments}%- + + brightness_level=$(${pkgs.brightnessctl}/bin/brightnessctl get) + + message="󰃠 Brightness: $brightness_level%" + + ${pkgs.libnotify}/bin/notify-send "$message" \ + -h int:value:"$brightness_level" \ + --replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification" + ''; + + screenshot = pkgs.writeShellScriptBin "screenshot" '' + if [[ $2 == "swappy" ]];then + folder="/tmp" + else + folder="$HOME/Pictures/screenshots" + fi + filename="$(date +%Y-%m-%d_%H:%M:%S).png" + mode="region" # Default to region + + if [[ $1 == "window" ]];then + mode="window" + elif [[ $1 == "monitor" ]];then + mode="output" + fi + + ${pkgs.hyprshot}/bin/hyprshot -m $mode -o $folder -f $filename -s || exit 1 + + if [[ $2 == "swappy" ]];then + ${pkgs.swappy}/bin/swappy -f "$folder/$filename" -o "$HOME/Pictures/screenshots/$filename" + exit 0 + fi + + message=" Screenshot saved" + + ${pkgs.libnotify}/bin/notify-send "$message" \ + --icon="$folder/$filename" \ + --replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification" + ''; + vault = pkgs.writeShellScriptBin "vault" '' nvim $HOME/Nextcloud/obsidian ''; -in { home.packages = with pkgs; [ menu powermenu vault ]; } +in { + home.packages = with pkgs; [ + menu + powermenu + brightness-up + brightness-down + brightness-change + screenshot + hyprshot + vault + ]; + +} diff --git a/home/desktop/hypr/scripts/screenshot.nix b/home/desktop/hypr/scripts/screenshot.nix deleted file mode 100644 index c64fbb2..0000000 --- a/home/desktop/hypr/scripts/screenshot.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs, config, ... }: - -let - homedir = config.home.homeDirectory; - - screenshot = pkgs.writeShellScriptBin "screenshot" '' - if [[ $2 == "swappy" ]];then - folder="/tmp" - else - folder="$HOME/Pictures/screenshots" - fi - filename="$(date +%Y-%m-%d_%H:%M:%S).png" - mode="region" # Default to region - - if [[ $1 == "window" ]];then - mode="window" - elif [[ $1 == "monitor" ]];then - mode="output" - fi - - ${pkgs.hyprshot}/bin/hyprshot -m $mode -o $folder -f $filename -s || exit 1 - - if [[ $2 == "swappy" ]];then - ${pkgs.swappy}/bin/swappy -f "$folder/$filename" -o "$HOME/Pictures/screenshots/$filename" - exit 0 - fi - - message=" Screenshot saved" - - ${pkgs.libnotify}/bin/notify-send "$message" \ - --icon="$folder/$filename" \ - --replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification" - ''; -in { home.packages = with pkgs; [ hyprshot screenshot ]; }