Moved scripts to the overlay folder to be used as packages
All scripts have been moved to the overlay folder in the top level directory Overlay is now instantiated per configuration to make use of the host variable
This commit is contained in:
19
overlay/scripts/wm-controls/chpaper.nix
Executable file
19
overlay/scripts/wm-controls/chpaper.nix
Executable file
@@ -0,0 +1,19 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chpaper";
|
||||
runtimeInputs = with pkgs; [ chafa fzf ripgrep findutils coreutils ];
|
||||
text = ''
|
||||
paper="$\{self}/assets/wallpapers/$(find "$FLAKEPATH"/assets/wallpapers -exec basename {} \; | rg "\.\w+$" | fzf --preview "chafa -s 30x40 $FLAKEPATH/assets/wallpapers/{}")"
|
||||
[ "$paper" = "$\{self}/assets/wallpapers/" ] && echo "Cancelling wallpaper change" && exit 1
|
||||
echo "$paper" | xargs -I {} sed -i '/wallpaper =/s|"[^"]*"|"{}"|' "$FLAKEPATH"/modules/sys/environment/stylix.nix
|
||||
echo "Successfully changed wallpaper. Rebuild now?" && \
|
||||
select choice in "Yes" "No"; do
|
||||
case $choice in
|
||||
"Yes")
|
||||
rebuild;systemctl --user restart hyprpaper;exit 0;;
|
||||
"No")
|
||||
echo "Exiting...";exit 0;;
|
||||
esac
|
||||
done
|
||||
'';
|
||||
}
|
||||
43
overlay/scripts/wm-controls/chscheme.nix
Executable file
43
overlay/scripts/wm-controls/chscheme.nix
Executable file
@@ -0,0 +1,43 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chscheme";
|
||||
runtimeInputs = with pkgs; [ base16-schemes fzf coreutils ];
|
||||
text = ''
|
||||
selected_scheme=$(/usr/bin/env ls "$(nix-build '<nixpkgs>' -A base16-schemes)"/share/themes | \
|
||||
sed 's/\.yaml//g' | \
|
||||
fzf --preview "cat $(nix-build '<nixpkgs>' -A base16-schemes)/share/themes/{}.yaml | \
|
||||
while IFS=\": \" read -r key value; do \
|
||||
if [[ \$key =~ base0[0-9A-F] ]]; then \
|
||||
clean_value=\$(echo \"\$value\" | tr -d '\"'); \
|
||||
r=\$((16#\''${clean_value:0:2})); \
|
||||
g=\$((16#\''${clean_value:2:2})); \
|
||||
b=\$((16#\''${clean_value:4:2})); \
|
||||
printf \"\\033[48;2;%d;%d;%dm %-20s %s \\033[0m\\n\" \$r \$g \$b \$key \$clean_value; \
|
||||
fi; \
|
||||
done")
|
||||
|
||||
if [[ -z "$selected_scheme" ]]; then
|
||||
echo "Aborting color scheme change."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! echo "$selected_scheme" | xargs -I {} sed -i '/^[[:space:]]*scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/modules/sys/environment/stylix.nix; then
|
||||
echo "Failed to change color scheme."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Successfully changed system color scheme. Rebuild now?"
|
||||
select choice in "Yes" "No"; do
|
||||
case $choice in
|
||||
"Yes")
|
||||
rebuild
|
||||
exit 0
|
||||
;;
|
||||
"No")
|
||||
echo "Exiting..."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
'';
|
||||
}
|
||||
40
overlay/scripts/wm-controls/keyring.nix
Executable file
40
overlay/scripts/wm-controls/keyring.nix
Executable file
@@ -0,0 +1,40 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "keyring";
|
||||
runtimeInputs = with pkgs; [
|
||||
pass
|
||||
findutils
|
||||
ripgrep
|
||||
fzf
|
||||
wl-clipboard
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
# prevent multiple instances, conditional check happens in the hyprland bind
|
||||
touch /tmp/keyringfile
|
||||
trap "[ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile" EXIT SIGHUP SIGINT
|
||||
|
||||
# get passwords from password store, remove .password store/ prefix and .gpg suffix, exlude .gpg-id file, open results in fzf
|
||||
pass_string=$(find "$HOME"/.password-store -type f | sed 's|.*/.password-store/||; s|\.gpg$||' | sed 's|^\([^/]*\)|\x1b[32m\1\x1b[0m|' | rg -v "\.git|.gpg-id" | sort -r | fzf --border --border-label="$(whoami)'s keyring" --ansi --layout=reverse)
|
||||
|
||||
# prevents cliphist from writing passwords to the clipboard history
|
||||
pkill -STOP wl-paste
|
||||
|
||||
# copy password
|
||||
pass -c "$pass_string" > /dev/null
|
||||
echo "Password copied. Clearing clipboard in 10 seconds."
|
||||
|
||||
# start a timer for 10 seconds, clear clipboard, resume cliphist tracking
|
||||
nohup bash <<-EOF > /dev/null &
|
||||
sleep 10
|
||||
wl-copy -c
|
||||
pkill -CONT wl-paste
|
||||
EOF
|
||||
|
||||
/run/current-system/sw/bin/rm /tmp/keyringfile
|
||||
sleep 0.5
|
||||
exit 0
|
||||
'';
|
||||
}
|
||||
62
overlay/scripts/wm-controls/mkscreenshots.nix
Normal file
62
overlay/scripts/wm-controls/mkscreenshots.nix
Normal file
@@ -0,0 +1,62 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mkscreenshots";
|
||||
runtimeInputs = with pkgs; [ jq neofetch kitty coreutils nemo grimblast git ];
|
||||
text = ''
|
||||
if [ -n "$(hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4")')" ]; then
|
||||
echo "There are windows in workspace 4. This script uses workspace 4, so move those windows and run it again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prev_workspace=$(hyprctl activeworkspace -j | jq '.id')
|
||||
|
||||
hyprctl dispatch focusmonitor 0
|
||||
|
||||
screenshotfetch() {
|
||||
neofetch
|
||||
|
||||
kitty @ scroll-window 20-
|
||||
|
||||
exec sleep infinity
|
||||
}
|
||||
|
||||
closewindows() {
|
||||
hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4") | .address' | while read -r addr; do
|
||||
hyprctl dispatch closewindow address:"$addr"
|
||||
done
|
||||
}
|
||||
|
||||
temp_script=$(mktemp)
|
||||
screenshotfetch_var=$(declare -f screenshotfetch)
|
||||
echo "$screenshotfetch_var" > "$temp_script"
|
||||
echo "screenshotfetch" >> "$temp_script"
|
||||
chmod +x "$temp_script"
|
||||
|
||||
hyprctl dispatch workspace 4
|
||||
hyprctl dispatch exec "[float;size 40% 25%;move 1% 66%] kitty bash -c '$temp_script'"
|
||||
hyprctl dispatch exec "[float;size 40% 50%;move 57% 8%] nemo"
|
||||
|
||||
sleep 1
|
||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-neofetch.png
|
||||
|
||||
closewindows
|
||||
|
||||
hyprctl dispatch exec 'kitty nvim'
|
||||
hyprctl dispatch exec 'kitty yazi'
|
||||
hyprctl dispatch exec 'kitty'
|
||||
|
||||
sleep 1
|
||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-busy.png
|
||||
|
||||
(
|
||||
cd "$FLAKEPATH"
|
||||
latest_hash=$(git rev-parse HEAD)
|
||||
sed -i "s|\(https://github.com/pagedMov/nixos-config/commit/\)[a-f0-9]\{40\}|\1$latest_hash|" "$FLAKEPATH"/README.md
|
||||
)
|
||||
|
||||
closewindows
|
||||
|
||||
hyprctl dispatch workspace "$prev_workspace"
|
||||
'';
|
||||
}
|
||||
80
overlay/scripts/wm-controls/moveonscreen.nix
Executable file
80
overlay/scripts/wm-controls/moveonscreen.nix
Executable file
@@ -0,0 +1,80 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "moveonscreen";
|
||||
runtimeInputs = with pkgs; [ hyprland jq coreutils gawk ];
|
||||
text = ''
|
||||
center_window=false
|
||||
if [[ ! $# -eq 0 ]] && [[ $1 == "--center" ]]; then
|
||||
center_window=true
|
||||
fi
|
||||
|
||||
cursor_pos=$(hyprctl cursorpos | sed 's/,//')
|
||||
cursor_x=$(echo "$cursor_pos" | awk '{print $1}')
|
||||
cursor_y=$(echo "$cursor_pos" | awk '{print $2}')
|
||||
|
||||
|
||||
window_info=$(hyprctl activewindow -j)
|
||||
window_width=$(echo "$window_info" | jq ".size[0]")
|
||||
window_height=$(echo "$window_info" | jq ".size[1]")
|
||||
|
||||
|
||||
if [ "$center_window" = true ]; then
|
||||
cursor_x=$((cursor_x - window_width / 2))
|
||||
cursor_y=$((cursor_y - window_height / 2))
|
||||
|
||||
if (( cursor_x < 10 )); then
|
||||
cursor_x=10
|
||||
fi
|
||||
if (( cursor_y < 54 )); then
|
||||
cursor_y=54
|
||||
fi
|
||||
fi
|
||||
|
||||
monitors=$(hyprctl monitors -j)
|
||||
|
||||
monitor_x_min=0
|
||||
monitor_x_max=0
|
||||
monitor_y_min=0
|
||||
monitor_y_max=0
|
||||
focused_monitor=-1
|
||||
|
||||
for ((i = 0; i < $(echo "$monitors" | jq 'length'); i++)); do
|
||||
mon_x=$(echo "$monitors" | jq ".[$i].x")
|
||||
mon_y=$(echo "$monitors" | jq ".[$i].y")
|
||||
mon_width=$(echo "$monitors" | jq ".[$i].width")
|
||||
mon_height=$(echo "$monitors" | jq ".[$i].height")
|
||||
is_focused=$(echo "$monitors" | jq ".[$i].focused")
|
||||
|
||||
if [ "$is_focused" = true ]; then
|
||||
monitor_x_min=$((mon_x + 10))
|
||||
monitor_x_max=$((mon_x + mon_width - 10))
|
||||
monitor_y_min=$((mon_y + 10))
|
||||
monitor_y_max=$((mon_y + mon_height - 10))
|
||||
focused_monitor=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$focused_monitor" -eq -1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if (( cursor_x < monitor_x_min )); then
|
||||
adjusted_x=$monitor_x_min
|
||||
elif (( cursor_x + window_width > monitor_x_max )); then
|
||||
adjusted_x=$((monitor_x_max - window_width))
|
||||
else
|
||||
adjusted_x=$cursor_x
|
||||
fi
|
||||
|
||||
if (( cursor_y < monitor_y_min )); then
|
||||
adjusted_y=$monitor_y_min
|
||||
elif (( cursor_y + window_height > monitor_y_max )); then
|
||||
adjusted_y=$((monitor_y_max - window_height))
|
||||
else
|
||||
adjusted_y=$cursor_y
|
||||
fi
|
||||
|
||||
hyprctl dispatch moveactive exact "$adjusted_x $adjusted_y" > /dev/null 2>&1
|
||||
'';
|
||||
}
|
||||
9
overlay/scripts/wm-controls/s_check.nix
Executable file
9
overlay/scripts/wm-controls/s_check.nix
Executable file
@@ -0,0 +1,9 @@
|
||||
{ pkgs, }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "scheck";
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
[ "$SOUNDS_ENABLED" -eq 1 ]
|
||||
'';
|
||||
}
|
||||
9
overlay/scripts/wm-controls/switchmon.nix
Executable file
9
overlay/scripts/wm-controls/switchmon.nix
Executable file
@@ -0,0 +1,9 @@
|
||||
{ pkgs, }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "switchmon";
|
||||
text = ''
|
||||
#!/bin/zsh
|
||||
|
||||
hyprctl dispatch focusmonitor "$(hyprctl -j monitors | jq -r '.[] | select(.focused == false) | .name')"
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user