removed mkbackup script, refactored all script files to use pkgs.writeShellApplication rather than pkgs.writeShellScriptBin
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
{pkgs}:
|
||||
pkgs.writeShellScriptBin "chpaper" ''
|
||||
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
|
||||
''
|
||||
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
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,40 +1,46 @@
|
||||
{pkgs}:
|
||||
pkgs.writeShellScriptBin "chscheme" ''
|
||||
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')
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chscheme";
|
||||
runtimeInputs = with pkgs; [
|
||||
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 [[ -z "$selected_scheme" ]]; then
|
||||
echo "Aborting color scheme change."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$selected_scheme" | xargs -I {} sed -i '/^[[:space:]]*scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/modules/sys/environment/stylix.nix
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to change color scheme."
|
||||
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
|
||||
''
|
||||
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
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,35 +1,42 @@
|
||||
{
|
||||
self,
|
||||
pkgs,
|
||||
...
|
||||
pkgs
|
||||
}:
|
||||
pkgs.writeShellScriptBin "keyring" ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
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
|
||||
# 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)
|
||||
# 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)
|
||||
|
||||
[ $? = 0 ] || { [ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile; exit 1; }
|
||||
# prevents cliphist from writing passwords to the clipboard history
|
||||
pkill -STOP wl-paste
|
||||
|
||||
# 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."
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
''
|
||||
/run/current-system/sw/bin/rm /tmp/keyringfile
|
||||
sleep 0.5
|
||||
exit 0
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,58 +1,70 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellScriptBin "mkscreenshots" ''
|
||||
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() {
|
||||
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
|
||||
|
||||
kitty @ scroll-window 20-
|
||||
prev_workspace=$(hyprctl activeworkspace -j | jq '.id')
|
||||
|
||||
exec sleep infinity
|
||||
}
|
||||
hyprctl dispatch focusmonitor 0
|
||||
|
||||
closewindows() {
|
||||
hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4") | .address' | while read -r addr; do
|
||||
hyprctl dispatch closewindow address:"$addr"
|
||||
done
|
||||
}
|
||||
screenshotfetch() {
|
||||
neofetch
|
||||
|
||||
temp_script=$(mktemp)
|
||||
screenshotfetch_var=$(declare -f screenshotfetch)
|
||||
echo "$screenshotfetch_var" > "$temp_script"
|
||||
echo "screenshotfetch" >> "$temp_script"
|
||||
chmod +x "$temp_script"
|
||||
kitty @ scroll-window 20-
|
||||
|
||||
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"
|
||||
exec sleep infinity
|
||||
}
|
||||
|
||||
sleep 1
|
||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-neofetch.png
|
||||
closewindows() {
|
||||
hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4") | .address' | while read -r addr; do
|
||||
hyprctl dispatch closewindow address:"$addr"
|
||||
done
|
||||
}
|
||||
|
||||
closewindows
|
||||
temp_script=$(mktemp)
|
||||
screenshotfetch_var=$(declare -f screenshotfetch)
|
||||
echo "$screenshotfetch_var" > "$temp_script"
|
||||
echo "screenshotfetch" >> "$temp_script"
|
||||
chmod +x "$temp_script"
|
||||
|
||||
hyprctl dispatch exec 'kitty nvim'
|
||||
hyprctl dispatch exec 'kitty yazi'
|
||||
hyprctl dispatch exec 'kitty'
|
||||
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-busy.png
|
||||
sleep 1
|
||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-neofetch.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
|
||||
|
||||
closewindows
|
||||
hyprctl dispatch exec 'kitty nvim'
|
||||
hyprctl dispatch exec 'kitty yazi'
|
||||
hyprctl dispatch exec 'kitty'
|
||||
|
||||
hyprctl dispatch workspace "$prev_workspace"
|
||||
''
|
||||
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"
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,76 +1,85 @@
|
||||
{pkgs}:
|
||||
pkgs.writeShellScriptBin "moveonscreen" ''
|
||||
center_window=false
|
||||
if [[ $1 == "--center" ]]; then
|
||||
center_window=true
|
||||
fi
|
||||
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}')
|
||||
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]")
|
||||
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 [ "$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
|
||||
if (( cursor_x < 10 )); then
|
||||
cursor_x=10
|
||||
fi
|
||||
if (( cursor_y < 54 )); then
|
||||
cursor_y=54
|
||||
fi
|
||||
fi
|
||||
|
||||
monitors=$(hyprctl monitors -j)
|
||||
monitors=$(hyprctl monitors -j)
|
||||
|
||||
monitor_x_min=0
|
||||
monitor_x_max=0
|
||||
monitor_y_min=0
|
||||
monitor_y_max=0
|
||||
focused_monitor=-1
|
||||
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")
|
||||
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 [ "$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 [ "$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_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
|
||||
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
|
||||
''
|
||||
hyprctl dispatch moveactive exact "$adjusted_x $adjusted_y" > /dev/null 2>&1
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{
|
||||
self,
|
||||
pkgs,
|
||||
}:
|
||||
pkgs.writeShellScriptBin "scheck" ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
pkgs.writeShellApplication {
|
||||
name = "scheck";
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
[ "$SOUNDS_ENABLED" -eq 1 ]
|
||||
''
|
||||
[ "$SOUNDS_ENABLED" -eq 1 ]
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{
|
||||
self,
|
||||
pkgs,
|
||||
}:
|
||||
pkgs.writeShellScriptBin "switchmon" ''
|
||||
#!/bin/zsh
|
||||
pkgs.writeShellApplication {
|
||||
name = "switchmon";
|
||||
text = ''
|
||||
#!/bin/zsh
|
||||
|
||||
hyprctl dispatch focusmonitor $(echo "$(hyprctl -j monitors)" | jq -r '.[] | select(.focused == false) | .name')
|
||||
''
|
||||
hyprctl dispatch focusmonitor "$(hyprctl -j monitors | jq -r '.[] | select(.focused == false) | .name')"
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user