diff --git a/modules/home/packages.nix b/modules/home/packages.nix index 05ce457..b5216a8 100644 --- a/modules/home/packages.nix +++ b/modules/home/packages.nix @@ -30,10 +30,8 @@ nitch # systhem fetch util nix-prefetch-github kdePackages.okular # KDE's pdf viewer/editor (supports digital signing) - ripgrep # grep replacement simple-scan orca-slicer - swappy tdf # cli pdf viewer speedcrunch thunderbird diff --git a/modules/home/scripts/scripts.nix b/modules/home/scripts/scripts.nix index 5d98602..520a9cc 100644 --- a/modules/home/scripts/scripts.nix +++ b/modules/home/scripts/scripts.nix @@ -1,45 +1,70 @@ -{pkgs, ...}: let - ddcmonitorctl = pkgs.writeShellScriptBin "ddcmonitorctl" (builtins.readFile ./scripts/ddcmonitorctl.sh); +{pkgs, ...}: { + home.packages = + [ + (pkgs.writeShellApplication { + name = "ddcmonitorctl"; + runtimeInputs = with pkgs; [ddcutil]; + text = builtins.readFile ./scripts/ddcmonitorctl.sh; + }) + ] + ++ (let + wall-change = pkgs.writeShellApplication { + name = "wall-change"; + runtimeInputs = with pkgs; [swaybg imagemagick]; + text = builtins.readFile ./scripts/wall-change.sh; + }; + setbg-apotd = pkgs.writeShellApplication { + name = "setbg-apotd"; + runtimeInputs = [pkgs.curl pkgs.gnugrep pkgs.gnused wall-change]; + text = builtins.readFile ./scripts/setbg-apotd.sh; + }; + setbg-bpotd = pkgs.writeShellApplication { + name = "setbg-bpotd"; + runtimeInputs = with pkgs; [pkgs.curl pkgs.jq wall-change]; + text = builtins.readFile ./scripts/setbg-bpotd.sh; + }; + wallpaper-picker = pkgs.writeShellApplication { + name = "wallpaper-picker"; + runtimeInputs = [pkgs.fuzzel setbg-apotd setbg-bpotd wall-change]; + text = builtins.readFile ./scripts/wallpaper-picker.sh; + }; + in [ + wall-change + setbg-apotd + setbg-bpotd + wallpaper-picker + ]) + ++ [ + (pkgs.writeShellApplication { + name = "runbg"; + text = builtins.readFile ./scripts/runbg.sh; + }) - setbg-apotd = pkgs.writeShellScriptBin "setbg-apotd" (builtins.readFile ./scripts/setbg-apotd.sh); - setbg-bpotd = pkgs.writeShellScriptBin "setbg-bpotd" (builtins.readFile ./scripts/setbg-bpotd.sh); - wall-change = pkgs.writeShellScriptBin "wall-change" (builtins.readFile ./scripts/wall-change.sh); - wallpaper-picker = pkgs.writeShellScriptBin "wallpaper-picker" (builtins.readFile ./scripts/wallpaper-picker.sh); + (pkgs.writeShellApplication { + name = "toggle_blur"; + text = builtins.readFile ./scripts/toggle_blur.sh; + }) + (pkgs.writeShellApplication { + name = "toggle_oppacity"; + text = builtins.readFile ./scripts/toggle_oppacity.sh; + }) - runbg = pkgs.writeShellScriptBin "runbg" (builtins.readFile ./scripts/runbg.sh); + (pkgs.writeShellApplication { + name = "shutdown-script"; + runtimeInputs = with pkgs; [fuzzel]; + text = builtins.readFile ./scripts/shutdown-script.sh; + }) - toggle_blur = pkgs.writeScriptBin "toggle_blur" (builtins.readFile ./scripts/toggle_blur.sh); - toggle_oppacity = pkgs.writeScriptBin "toggle_oppacity" (builtins.readFile ./scripts/toggle_oppacity.sh); + (pkgs.writeShellApplication { + name = "show-keybinds"; + runtimeInputs = with pkgs; [fuzzel gnugrep]; + text = builtins.readFile ./scripts/show-keybinds.sh; + }) - compress = pkgs.writeScriptBin "compress" (builtins.readFile ./scripts/compress.sh); - extract = pkgs.writeScriptBin "extract" (builtins.readFile ./scripts/extract.sh); - - shutdown-script = pkgs.writeScriptBin "shutdown-script" (builtins.readFile ./scripts/shutdown-script.sh); - - show-keybinds = pkgs.writeScriptBin "show-keybinds" (builtins.readFile ./scripts/keybinds.sh); - - screenshot-menu = pkgs.writeScriptBin "screenshot-menu" (builtins.readFile ./scripts/screenshot-menu.sh); -in { - home.packages = with pkgs; [ - ddcmonitorctl - - setbg-apotd - setbg-bpotd - wall-change - wallpaper-picker - - runbg - - toggle_blur - toggle_oppacity - - compress - extract - - shutdown-script - - show-keybinds - - screenshot-menu - ]; + (pkgs.writeShellApplication { + name = "screenshot-menu"; + runtimeInputs = with pkgs; [fuzzel grimblast swappy]; + text = builtins.readFile ./scripts/screenshot-menu.sh; + }) + ]; } diff --git a/modules/home/scripts/scripts/compress.sh b/modules/home/scripts/scripts/compress.sh deleted file mode 100755 index 5c31e62..0000000 --- a/modules/home/scripts/scripts/compress.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -if (( $# == 1 )) then - # echo -ne "Archive name: " - # read name - # tar -cvzf "$name.tar.gz" $1 - tar -cvzf "$1.tar.gz" $1 -else - echo "Wrong number of arguments..." -fi \ No newline at end of file diff --git a/modules/home/scripts/scripts/ddcmonitorctl.sh b/modules/home/scripts/scripts/ddcmonitorctl.sh index b51f309..646d490 100755 --- a/modules/home/scripts/scripts/ddcmonitorctl.sh +++ b/modules/home/scripts/scripts/ddcmonitorctl.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - if [ "$1" == "on" ]; then state_opt=1 elif [ "$1" == "off" ]; then @@ -13,4 +11,4 @@ fi monitor_count=$(bash -c "ddcutil detect | grep Display | wc -l") -seq $monitor_count | xargs -n 1 ddcutil setvcp d6 $state_opt -d \ No newline at end of file +seq "$monitor_count" | xargs -n 1 ddcutil setvcp d6 $state_opt -d \ No newline at end of file diff --git a/modules/home/scripts/scripts/extract.sh b/modules/home/scripts/scripts/extract.sh deleted file mode 100755 index ecc25dd..0000000 --- a/modules/home/scripts/scripts/extract.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -for i in "$@" ; do - tar -xvzf $i - break -done diff --git a/modules/home/scripts/scripts/runbg.sh b/modules/home/scripts/scripts/runbg.sh index dc5088d..10c618b 100755 --- a/modules/home/scripts/scripts/runbg.sh +++ b/modules/home/scripts/scripts/runbg.sh @@ -1,12 +1,10 @@ -#!/usr/bin/env bash - [ $# -eq 0 ] && { # $# is number of args - echo "$(basename $0): missing command" >&2 + echo "$(basename "$0"): missing command" >&2 exit 1 } prog="$(which "$1")" # see below [ -z "$prog" ] && { - echo "$(basename $0): unknown command: $1" >&2 + echo "$(basename "$0"): unknown command: $1" >&2 exit 1 } shift # remove $1, now $prog, from args diff --git a/modules/home/scripts/scripts/screenshot-menu.sh b/modules/home/scripts/scripts/screenshot-menu.sh index 7802cf9..0baabfc 100755 --- a/modules/home/scripts/scripts/screenshot-menu.sh +++ b/modules/home/scripts/scripts/screenshot-menu.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - #### Options option_1="󰹑 Capture" @@ -37,19 +35,14 @@ timer_menu() { selected_timer="$(timer_cmd)" if [[ "$selected_timer" == "$option_time_1" ]]; then countdown=5 - ${1} elif [[ "$selected_timer" == "$option_time_2" ]]; then countdown=10 - ${1} elif [[ "$selected_timer" == "$option_time_3" ]]; then countdown=20 - ${1} elif [[ "$selected_timer" == "$option_time_4" ]]; then countdown=30 - ${1} elif [[ "$selected_timer" == "$option_time_5" ]]; then countdown=60 - ${1} fi } @@ -66,13 +59,10 @@ type_screenshot_menu() { selected_type_screenshot="$(type_screenshot_cmd)" if [[ "$selected_type_screenshot" == "$option_capture_1" ]]; then option_type_screenshot=screen - ${1} elif [[ "$selected_type_screenshot" == "$option_capture_2" ]]; then option_type_screenshot=output - ${1} elif [[ "$selected_type_screenshot" == "$option_capture_3" ]]; then option_type_screenshot=area - ${1} fi } diff --git a/modules/home/scripts/scripts/setbg-apotd.sh b/modules/home/scripts/scripts/setbg-apotd.sh index 98ef083..702562b 100755 --- a/modules/home/scripts/scripts/setbg-apotd.sh +++ b/modules/home/scripts/scripts/setbg-apotd.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - ## Based on https://github.com/sgsax/apod-desktop/blob/master/apod @@ -13,22 +11,19 @@ IMG_FILE=/tmp/apotd.jpg echo Getting APOD page... -page_data=`curl -s $PAGE_URL` - -if [ $? -ne 0 ]; then +if ! page_data=$(curl -s $PAGE_URL); then echo "Unable to retrieve page"; exit 1; fi # extract the image url from the astropix page echo Getting image url... -imgurl=`echo "$page_data" | grep -i "img src" | sed -e 's/.*/dev/null ; then hyprctl keyword decoration:blur:enabled false >/dev/null else diff --git a/modules/home/scripts/scripts/toggle_oppacity.sh b/modules/home/scripts/scripts/toggle_oppacity.sh index 9f1062e..43f3298 100755 --- a/modules/home/scripts/scripts/toggle_oppacity.sh +++ b/modules/home/scripts/scripts/toggle_oppacity.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - if hyprctl getoption decoration:active_opacity | grep "float: 1" >/dev/null ; then hyprctl keyword decoration:active_opacity 0.90 >/dev/null hyprctl keyword decoration:inactive_opacity 0.90 >/dev/null diff --git a/modules/home/scripts/scripts/wall-change.sh b/modules/home/scripts/scripts/wall-change.sh index 0193024..bf66f89 100644 --- a/modules/home/scripts/scripts/wall-change.sh +++ b/modules/home/scripts/scripts/wall-change.sh @@ -1,11 +1,9 @@ -#!/usr/bin/env bash - PIDS=$(pgrep -f "swaybg") -swaybg -m fill -i $1 & +swaybg -m fill -i "$1" & if [ -n "$PIDS" ]; then echo "$PIDS" | xargs kill fi -magick $1 ~/.config/hypr/wallpaper.png +magick "$1" ~/.config/hypr/wallpaper.png diff --git a/modules/home/scripts/scripts/wallpaper-picker.sh b/modules/home/scripts/scripts/wallpaper-picker.sh index f129e47..bb1d0c9 100755 --- a/modules/home/scripts/scripts/wallpaper-picker.sh +++ b/modules/home/scripts/scripts/wallpaper-picker.sh @@ -1,16 +1,14 @@ -#!/usr/bin/env bash - bpotd_entry="⚙️ Bing's Picture Of The Day" apotd_entry="⚙️ NASA's Astronomy Picture Of The Day" wallpapers_folder=$HOME/Pictures/Wallpapers/ -wallpaper_name=`echo -e "$bpotd_entry\n$apotd_entry" | { cat; find $wallpapers_folder -type f | sed "s|$wallpapers_folder||"; } | fuzzel --dmenu` +wallpaper_name=$(echo -e "$bpotd_entry\n$apotd_entry" | { cat; find "$wallpapers_folder" -type f | sed "s|$wallpapers_folder||"; } | fuzzel --dmenu) if [ "$wallpaper_name" == "$bpotd_entry" ]; then setbg-bpotd elif [ "$wallpaper_name" == "$apotd_entry" ]; then setbg-apotd elif [[ -f $wallpapers_folder/$wallpaper_name ]]; then - wall-change $wallpapers_folder/$wallpaper_name + wall-change "$wallpapers_folder/$wallpaper_name" else exit 1 fi \ No newline at end of file