Migrate config (frues-pc machine for now) from https://git.peprolinbot.com/peprolinbot/nixos-config, with improvements
This commit is contained in:
parent
ebd178b0a5
commit
7606f9e051
66 changed files with 9465 additions and 73 deletions
70
users/pedro/home-configuration/scripts/default.nix
Normal file
70
users/pedro/home-configuration/scripts/default.nix
Normal file
|
@ -0,0 +1,70 @@
|
|||
{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;
|
||||
})
|
||||
|
||||
(pkgs.writeShellApplication {
|
||||
name = "toggle_blur";
|
||||
text = builtins.readFile ./scripts/toggle_blur.sh;
|
||||
})
|
||||
(pkgs.writeShellApplication {
|
||||
name = "toggle_oppacity";
|
||||
text = builtins.readFile ./scripts/toggle_oppacity.sh;
|
||||
})
|
||||
|
||||
(pkgs.writeShellApplication {
|
||||
name = "shutdown-script";
|
||||
runtimeInputs = with pkgs; [fuzzel];
|
||||
text = builtins.readFile ./scripts/shutdown-script.sh;
|
||||
})
|
||||
|
||||
(pkgs.writeShellApplication {
|
||||
name = "show-keybinds";
|
||||
runtimeInputs = with pkgs; [fuzzel gnugrep];
|
||||
text = builtins.readFile ./scripts/show-keybinds.sh;
|
||||
})
|
||||
|
||||
(pkgs.writeShellApplication {
|
||||
name = "screenshot-menu";
|
||||
runtimeInputs = with pkgs; [fuzzel grimblast swappy];
|
||||
text = builtins.readFile ./scripts/screenshot-menu.sh;
|
||||
})
|
||||
];
|
||||
}
|
14
users/pedro/home-configuration/scripts/scripts/ddcmonitorctl.sh
Executable file
14
users/pedro/home-configuration/scripts/scripts/ddcmonitorctl.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
if [ "$1" == "on" ]; then
|
||||
state_opt=1
|
||||
elif [ "$1" == "off" ]; then
|
||||
state_opt=4
|
||||
else
|
||||
echo "First argument must be either 'on' or 'off'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
monitor_count=$(bash -c "ddcutil detect | grep Display | wc -l")
|
||||
|
||||
seq "$monitor_count" | xargs -n 1 ddcutil setvcp d6 $state_opt -d
|
14
users/pedro/home-configuration/scripts/scripts/runbg.sh
Executable file
14
users/pedro/home-configuration/scripts/scripts/runbg.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
[ $# -eq 0 ] && { # $# is number of args
|
||||
echo "$(basename "$0"): missing command" >&2
|
||||
exit 1
|
||||
}
|
||||
prog="$(which "$1")" # see below
|
||||
[ -z "$prog" ] && {
|
||||
echo "$(basename "$0"): unknown command: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
shift # remove $1, now $prog, from args
|
||||
tty -s && exec </dev/null # if stdin is a terminal, redirect from null
|
||||
tty -s <&1 && exec >/dev/null # if stdout is a terminal, redirect to null
|
||||
tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null)
|
||||
"$prog" "$@" & # $@ is all args
|
114
users/pedro/home-configuration/scripts/scripts/screenshot-menu.sh
Executable file
114
users/pedro/home-configuration/scripts/scripts/screenshot-menu.sh
Executable file
|
@ -0,0 +1,114 @@
|
|||
#### Options
|
||||
|
||||
option_1=" Capture"
|
||||
option_2=" Timer capture"
|
||||
|
||||
option_capture_1=" All Screen"
|
||||
option_capture_2=" Capture Active Screen"
|
||||
option_capture_3=" Capture Area/Window/Application"
|
||||
|
||||
option_time_1="5s"
|
||||
option_time_2="10s"
|
||||
option_time_3="20s"
|
||||
option_time_4="30s"
|
||||
option_time_5="60s"
|
||||
|
||||
####
|
||||
|
||||
|
||||
#### Initial menu to decide wether a timer is wanted
|
||||
|
||||
want_timer_cmd() {
|
||||
echo -e "$option_1\n$option_2" | fuzzel --dmenu -p 'Screenshot: '
|
||||
}
|
||||
|
||||
####
|
||||
|
||||
|
||||
#### Choose Timer seconds
|
||||
|
||||
timer_cmd() {
|
||||
echo -e "$option_time_1\n$option_time_2\n$option_time_3\n$option_time_4\n$option_time_5" | fuzzel --dmenu -p 'Choose timer: '
|
||||
}
|
||||
|
||||
timer_menu() {
|
||||
selected_timer="$(timer_cmd)"
|
||||
if [[ "$selected_timer" == "$option_time_1" ]]; then
|
||||
countdown=5
|
||||
elif [[ "$selected_timer" == "$option_time_2" ]]; then
|
||||
countdown=10
|
||||
elif [[ "$selected_timer" == "$option_time_3" ]]; then
|
||||
countdown=20
|
||||
elif [[ "$selected_timer" == "$option_time_4" ]]; then
|
||||
countdown=30
|
||||
elif [[ "$selected_timer" == "$option_time_5" ]]; then
|
||||
countdown=60
|
||||
fi
|
||||
}
|
||||
|
||||
####
|
||||
|
||||
|
||||
#### Chose Screenshot Type
|
||||
|
||||
type_screenshot_cmd() {
|
||||
echo -e "$option_capture_1\n$option_capture_2\n$option_capture_3" | fuzzel --dmenu -p 'Type of screenshot: '
|
||||
}
|
||||
|
||||
type_screenshot_menu() {
|
||||
selected_type_screenshot="$(type_screenshot_cmd)"
|
||||
if [[ "$selected_type_screenshot" == "$option_capture_1" ]]; then
|
||||
option_type_screenshot=screen
|
||||
elif [[ "$selected_type_screenshot" == "$option_capture_2" ]]; then
|
||||
option_type_screenshot=output
|
||||
elif [[ "$selected_type_screenshot" == "$option_capture_3" ]]; then
|
||||
option_type_screenshot=area
|
||||
fi
|
||||
}
|
||||
|
||||
####
|
||||
|
||||
|
||||
### Run the timer
|
||||
|
||||
timer() {
|
||||
# Countdown notifications must start at 10 seconds so they aren't annoying
|
||||
if [[ $countdown -gt 10 ]]; then
|
||||
notify-send -t 1000 "Taking Screenshot in ${countdown} seconds"
|
||||
sleep $((countdown - 10))
|
||||
countdown=10
|
||||
fi
|
||||
while [[ $countdown -ne 0 ]]; do
|
||||
notify-send -t 900 "Taking Screenshot in ${countdown}"
|
||||
countdown=$((countdown - 1))
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
####
|
||||
|
||||
|
||||
#### Main logic
|
||||
|
||||
chosen="$(want_timer_cmd)"
|
||||
if [ -z "$chosen" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
type_screenshot_menu
|
||||
if [ -z "$selected_type_screenshot" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $option_2 == *$chosen* ]]; then
|
||||
timer_menu
|
||||
if [ -z "$selected_timer" ]; then
|
||||
exit
|
||||
fi
|
||||
timer
|
||||
else
|
||||
sleep 0.7 # So fuzzel has time to fade-out
|
||||
fi
|
||||
GRIMBLAST_EDITOR="swappy -f " grimblast --notify edit "$option_type_screenshot"
|
||||
|
||||
####
|
32
users/pedro/home-configuration/scripts/scripts/setbg-apotd.sh
Executable file
32
users/pedro/home-configuration/scripts/scripts/setbg-apotd.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
## Based on https://github.com/sgsax/apod-desktop/blob/master/apod
|
||||
|
||||
|
||||
# base URL for the APOD website
|
||||
BASE_URL=https://apod.nasa.gov/apod/
|
||||
|
||||
# API endpoint which returns the Picture Of The Day data
|
||||
PAGE_URL="$BASE_URL/astropix.html"
|
||||
|
||||
IMG_FILE=/tmp/apotd.jpg
|
||||
|
||||
|
||||
echo Getting APOD page...
|
||||
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/.*<img src="\(.*\)".*/\1/i')
|
||||
echo "Image url is $imgurl"
|
||||
|
||||
# get that image file
|
||||
echo "Getting image at ${BASE_URL}${imgurl}"
|
||||
if ! curl "${BASE_URL}${imgurl}" -o $IMG_FILE; then
|
||||
echo "Unable to retrieve image"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
#set wallpaper using swaybg
|
||||
wall-change "$IMG_FILE"
|
29
users/pedro/home-configuration/scripts/scripts/setbg-bpotd.sh
Executable file
29
users/pedro/home-configuration/scripts/scripts/setbg-bpotd.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
# base URL for Bing
|
||||
BASE_URL=https://bing.com
|
||||
|
||||
# API endpoint which returns the Picture Of The Day data
|
||||
ENDPOINT="$BASE_URL/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US"
|
||||
|
||||
IMG_FILE=/tmp/bpotd.jpg
|
||||
|
||||
|
||||
echo Querying the API...
|
||||
if ! api_data=$(curl "$ENDPOINT"); then
|
||||
echo "Unable to contact the API";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# extract the image url from the astropix page
|
||||
echo Getting image url...
|
||||
imgurl=$(echo "$api_data" | jq -r .images[0].url)
|
||||
echo "Image url is $imgurl"
|
||||
|
||||
# get that image file
|
||||
echo "Getting image at ${BASE_URL}${imgurl}"
|
||||
if ! curl "${BASE_URL}${imgurl}" -o $IMG_FILE; then
|
||||
echo "Unable to retrieve image"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
#set wallpaper using swaybg
|
||||
wall-change "$IMG_FILE"
|
4
users/pedro/home-configuration/scripts/scripts/show-keybinds.sh
Executable file
4
users/pedro/home-configuration/scripts/scripts/show-keybinds.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
config_file=~/.config/hypr/hyprland.conf
|
||||
keybinds=$(grep -oP '(?<=bind=).*' $config_file)
|
||||
keybinds=$(echo "$keybinds" | sed 's/,\([^,]*\)$/ = \1/' | sed 's/, exec//g' | sed 's/^,//g')
|
||||
fuzzel --width 75 --dmenu <<< "$keybinds"
|
13
users/pedro/home-configuration/scripts/scripts/shutdown-script.sh
Executable file
13
users/pedro/home-configuration/scripts/scripts/shutdown-script.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
respond="$(echo -e " Shutdown\n Restart\n Cancel" | fuzzel --dmenu --lines=3 --width=15 --prompt='Choose action: ')"
|
||||
|
||||
if [ "$respond" = ' Shutdown' ]
|
||||
then
|
||||
echo "shutdown"
|
||||
shutdown now
|
||||
elif [ "$respond" = ' Restart' ]
|
||||
then
|
||||
echo "restart"
|
||||
reboot
|
||||
else
|
||||
notify-send "Shutdown cancelled"
|
||||
fi
|
5
users/pedro/home-configuration/scripts/scripts/toggle_blur.sh
Executable file
5
users/pedro/home-configuration/scripts/scripts/toggle_blur.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
if hyprctl getoption decoration:blur:enabled | grep "int: 1" >/dev/null ; then
|
||||
hyprctl keyword decoration:blur:enabled false >/dev/null
|
||||
else
|
||||
hyprctl keyword decoration:blur:enabled true >/dev/null
|
||||
fi
|
7
users/pedro/home-configuration/scripts/scripts/toggle_oppacity.sh
Executable file
7
users/pedro/home-configuration/scripts/scripts/toggle_oppacity.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
else
|
||||
hyprctl keyword decoration:active_opacity 1 >/dev/null
|
||||
hyprctl keyword decoration:inactive_opacity 1 >/dev/null
|
||||
fi
|
|
@ -0,0 +1,9 @@
|
|||
PIDS=$(pgrep -f "swaybg")
|
||||
|
||||
swaybg -m fill -i "$1" &
|
||||
|
||||
if [ -n "$PIDS" ]; then
|
||||
echo "$PIDS" | xargs kill
|
||||
fi
|
||||
|
||||
magick "$1" ~/.config/hypr/wallpaper.png
|
14
users/pedro/home-configuration/scripts/scripts/wallpaper-picker.sh
Executable file
14
users/pedro/home-configuration/scripts/scripts/wallpaper-picker.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
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)
|
||||
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"
|
||||
else
|
||||
exit 1
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue