Update scripts

This commit is contained in:
Pedro Rey Anca 2024-12-30 16:05:37 +01:00
parent 1c008d576a
commit d337902211
Signed by: peprolinbot
GPG key ID: 053EA6E00116533A
15 changed files with 86 additions and 115 deletions

View file

@ -30,10 +30,8 @@
nitch # systhem fetch util nitch # systhem fetch util
nix-prefetch-github nix-prefetch-github
kdePackages.okular # KDE's pdf viewer/editor (supports digital signing) kdePackages.okular # KDE's pdf viewer/editor (supports digital signing)
ripgrep # grep replacement
simple-scan simple-scan
orca-slicer orca-slicer
swappy
tdf # cli pdf viewer tdf # cli pdf viewer
speedcrunch speedcrunch
thunderbird thunderbird

View file

@ -1,45 +1,70 @@
{pkgs, ...}: let {pkgs, ...}: {
ddcmonitorctl = pkgs.writeShellScriptBin "ddcmonitorctl" (builtins.readFile ./scripts/ddcmonitorctl.sh); 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); (pkgs.writeShellApplication {
setbg-bpotd = pkgs.writeShellScriptBin "setbg-bpotd" (builtins.readFile ./scripts/setbg-bpotd.sh); name = "toggle_blur";
wall-change = pkgs.writeShellScriptBin "wall-change" (builtins.readFile ./scripts/wall-change.sh); text = builtins.readFile ./scripts/toggle_blur.sh;
wallpaper-picker = pkgs.writeShellScriptBin "wallpaper-picker" (builtins.readFile ./scripts/wallpaper-picker.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); (pkgs.writeShellApplication {
toggle_oppacity = pkgs.writeScriptBin "toggle_oppacity" (builtins.readFile ./scripts/toggle_oppacity.sh); name = "show-keybinds";
runtimeInputs = with pkgs; [fuzzel gnugrep];
text = builtins.readFile ./scripts/show-keybinds.sh;
})
compress = pkgs.writeScriptBin "compress" (builtins.readFile ./scripts/compress.sh); (pkgs.writeShellApplication {
extract = pkgs.writeScriptBin "extract" (builtins.readFile ./scripts/extract.sh); name = "screenshot-menu";
runtimeInputs = with pkgs; [fuzzel grimblast swappy];
shutdown-script = pkgs.writeScriptBin "shutdown-script" (builtins.readFile ./scripts/shutdown-script.sh); text = builtins.readFile ./scripts/screenshot-menu.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
];
} }

View file

@ -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

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
if [ "$1" == "on" ]; then if [ "$1" == "on" ]; then
state_opt=1 state_opt=1
elif [ "$1" == "off" ]; then elif [ "$1" == "off" ]; then
@ -13,4 +11,4 @@ fi
monitor_count=$(bash -c "ddcutil detect | grep Display | wc -l") monitor_count=$(bash -c "ddcutil detect | grep Display | wc -l")
seq $monitor_count | xargs -n 1 ddcutil setvcp d6 $state_opt -d seq "$monitor_count" | xargs -n 1 ddcutil setvcp d6 $state_opt -d

View file

@ -1,6 +0,0 @@
#!/usr/bin/env bash
for i in "$@" ; do
tar -xvzf $i
break
done

View file

@ -1,12 +1,10 @@
#!/usr/bin/env bash
[ $# -eq 0 ] && { # $# is number of args [ $# -eq 0 ] && { # $# is number of args
echo "$(basename $0): missing command" >&2 echo "$(basename "$0"): missing command" >&2
exit 1 exit 1
} }
prog="$(which "$1")" # see below prog="$(which "$1")" # see below
[ -z "$prog" ] && { [ -z "$prog" ] && {
echo "$(basename $0): unknown command: $1" >&2 echo "$(basename "$0"): unknown command: $1" >&2
exit 1 exit 1
} }
shift # remove $1, now $prog, from args shift # remove $1, now $prog, from args

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
#### Options #### Options
option_1="󰹑 Capture" option_1="󰹑 Capture"
@ -37,19 +35,14 @@ timer_menu() {
selected_timer="$(timer_cmd)" selected_timer="$(timer_cmd)"
if [[ "$selected_timer" == "$option_time_1" ]]; then if [[ "$selected_timer" == "$option_time_1" ]]; then
countdown=5 countdown=5
${1}
elif [[ "$selected_timer" == "$option_time_2" ]]; then elif [[ "$selected_timer" == "$option_time_2" ]]; then
countdown=10 countdown=10
${1}
elif [[ "$selected_timer" == "$option_time_3" ]]; then elif [[ "$selected_timer" == "$option_time_3" ]]; then
countdown=20 countdown=20
${1}
elif [[ "$selected_timer" == "$option_time_4" ]]; then elif [[ "$selected_timer" == "$option_time_4" ]]; then
countdown=30 countdown=30
${1}
elif [[ "$selected_timer" == "$option_time_5" ]]; then elif [[ "$selected_timer" == "$option_time_5" ]]; then
countdown=60 countdown=60
${1}
fi fi
} }
@ -66,13 +59,10 @@ type_screenshot_menu() {
selected_type_screenshot="$(type_screenshot_cmd)" selected_type_screenshot="$(type_screenshot_cmd)"
if [[ "$selected_type_screenshot" == "$option_capture_1" ]]; then if [[ "$selected_type_screenshot" == "$option_capture_1" ]]; then
option_type_screenshot=screen option_type_screenshot=screen
${1}
elif [[ "$selected_type_screenshot" == "$option_capture_2" ]]; then elif [[ "$selected_type_screenshot" == "$option_capture_2" ]]; then
option_type_screenshot=output option_type_screenshot=output
${1}
elif [[ "$selected_type_screenshot" == "$option_capture_3" ]]; then elif [[ "$selected_type_screenshot" == "$option_capture_3" ]]; then
option_type_screenshot=area option_type_screenshot=area
${1}
fi fi
} }

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
## Based on https://github.com/sgsax/apod-desktop/blob/master/apod ## Based on https://github.com/sgsax/apod-desktop/blob/master/apod
@ -13,22 +11,19 @@ IMG_FILE=/tmp/apotd.jpg
echo Getting APOD page... echo Getting APOD page...
page_data=`curl -s $PAGE_URL` if ! page_data=$(curl -s $PAGE_URL); then
if [ $? -ne 0 ]; then
echo "Unable to retrieve page"; echo "Unable to retrieve page";
exit 1; exit 1;
fi fi
# extract the image url from the astropix page # extract the image url from the astropix page
echo Getting image url... echo Getting image url...
imgurl=`echo "$page_data" | grep -i "img src" | sed -e 's/.*<img src="\(.*\)".*/\1/i'` imgurl=$(echo "$page_data" | grep -i "img src" | sed -e 's/.*<img src="\(.*\)".*/\1/i')
echo Image url is $imgurl echo "Image url is $imgurl"
# get that image file # get that image file
echo Getting image at ${BASE_URL}${imgurl} echo "Getting image at ${BASE_URL}${imgurl}"
curl ${BASE_URL}${imgurl} -o $IMG_FILE if ! curl "${BASE_URL}${imgurl}" -o $IMG_FILE; then
if [ $? -ne 0 ]; then
echo "Unable to retrieve image" echo "Unable to retrieve image"
exit 2 exit 2
fi fi

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
# base URL for Bing # base URL for Bing
BASE_URL=https://bing.com BASE_URL=https://bing.com
@ -10,22 +8,19 @@ IMG_FILE=/tmp/bpotd.jpg
echo Querying the API... echo Querying the API...
api_data=`curl $ENDPOINT` if ! api_data=$(curl "$ENDPOINT"); then
if [ $? -ne 0 ]; then
echo "Unable to contact the API"; echo "Unable to contact the API";
exit 1; exit 1;
fi fi
# extract the image url from the astropix page # extract the image url from the astropix page
echo Getting image url... echo Getting image url...
imgurl=`echo $api_data | jq -r .images[0].url` imgurl=$(echo "$api_data" | jq -r .images[0].url)
echo Image url is $imgurl echo "Image url is $imgurl"
# get that image file # get that image file
echo Getting image at ${BASE_URL}${imgurl} echo "Getting image at ${BASE_URL}${imgurl}"
curl ${BASE_URL}${imgurl} -o $IMG_FILE if ! curl "${BASE_URL}${imgurl}" -o $IMG_FILE; then
if [ $? -ne 0 ]; then
echo "Unable to retrieve image" echo "Unable to retrieve image"
exit 2 exit 2
fi fi

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
config_file=~/.config/hypr/hyprland.conf config_file=~/.config/hypr/hyprland.conf
keybinds=$(grep -oP '(?<=bind=).*' $config_file) keybinds=$(grep -oP '(?<=bind=).*' $config_file)
keybinds=$(echo "$keybinds" | sed 's/,\([^,]*\)$/ = \1/' | sed 's/, exec//g' | sed 's/^,//g') keybinds=$(echo "$keybinds" | sed 's/,\([^,]*\)$/ = \1/' | sed 's/, exec//g' | sed 's/^,//g')

View file

@ -1,15 +1,13 @@
#!/usr/bin/env zsh respond="$(echo -e "󰐥 Shutdown\n󰜉 Restart\n󰜺 Cancel" | fuzzel --dmenu --lines=3 --width=15 --prompt='Choose action: ')"
respond="$(echo " Shutdown\n Restart\n Cancel" | fuzzel --dmenu --lines=3 --width=10 --prompt='')" if [ "$respond" = '󰐥 Shutdown' ]
if [ $respond = ' Shutdown' ]
then then
echo "shutdown" echo "shutdown"
shutdown now shutdown now
elif [ $respond = ' Restart' ] elif [ "$respond" = '󰜉 Restart' ]
then then
echo "restart" echo "restart"
reboot reboot
else else
notify-send "cancel shutdown" notify-send "Shutdown cancelled"
fi fi

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
if hyprctl getoption decoration:blur:enabled | grep "int: 1" >/dev/null ; then if hyprctl getoption decoration:blur:enabled | grep "int: 1" >/dev/null ; then
hyprctl keyword decoration:blur:enabled false >/dev/null hyprctl keyword decoration:blur:enabled false >/dev/null
else else

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
if hyprctl getoption decoration:active_opacity | grep "float: 1" >/dev/null ; then if hyprctl getoption decoration:active_opacity | grep "float: 1" >/dev/null ; then
hyprctl keyword decoration:active_opacity 0.90 >/dev/null hyprctl keyword decoration:active_opacity 0.90 >/dev/null
hyprctl keyword decoration:inactive_opacity 0.90 >/dev/null hyprctl keyword decoration:inactive_opacity 0.90 >/dev/null

View file

@ -1,11 +1,9 @@
#!/usr/bin/env bash
PIDS=$(pgrep -f "swaybg") PIDS=$(pgrep -f "swaybg")
swaybg -m fill -i $1 & swaybg -m fill -i "$1" &
if [ -n "$PIDS" ]; then if [ -n "$PIDS" ]; then
echo "$PIDS" | xargs kill echo "$PIDS" | xargs kill
fi fi
magick $1 ~/.config/hypr/wallpaper.png magick "$1" ~/.config/hypr/wallpaper.png

View file

@ -1,16 +1,14 @@
#!/usr/bin/env bash
bpotd_entry="⚙️ Bing's Picture Of The Day" bpotd_entry="⚙️ Bing's Picture Of The Day"
apotd_entry="⚙️ NASA's Astronomy Picture Of The Day" apotd_entry="⚙️ NASA's Astronomy Picture Of The Day"
wallpapers_folder=$HOME/Pictures/Wallpapers/ 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 if [ "$wallpaper_name" == "$bpotd_entry" ]; then
setbg-bpotd setbg-bpotd
elif [ "$wallpaper_name" == "$apotd_entry" ]; then elif [ "$wallpaper_name" == "$apotd_entry" ]; then
setbg-apotd setbg-apotd
elif [[ -f $wallpapers_folder/$wallpaper_name ]]; then elif [[ -f $wallpapers_folder/$wallpaper_name ]]; then
wall-change $wallpapers_folder/$wallpaper_name wall-change "$wallpapers_folder/$wallpaper_name"
else else
exit 1 exit 1
fi fi