formatted nix files using alejandra

This commit is contained in:
pagedmov
2024-10-31 22:33:10 -04:00
parent c6d381fc58
commit 495d90b0de
45 changed files with 1537 additions and 1504 deletions

View File

@@ -1,16 +1,15 @@
{ pkgs }:
{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"/flake.nix
echo "Successfully changed wallpaper. Rebuild now?" && \
select choice in "Yes" "No"; do
case $choice in
"Yes")
rebuild;pkill -9 hyprpaper;exit 0;;
"No")
echo "Exiting...";exit 0;;
esac
done
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"/flake.nix
echo "Successfully changed wallpaper. Rebuild now?" && \
select choice in "Yes" "No"; do
case $choice in
"Yes")
rebuild;pkill -9 hyprpaper;exit 0;;
"No")
echo "Exiting...";exit 0;;
esac
done
''

View File

@@ -1,42 +1,40 @@
{
pkgs,
}:
{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')
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 '/base16scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/flake.nix
if [ $? -ne 0 ]; then
echo "Failed to change color scheme."
exit 1
fi
echo "$selected_scheme" | xargs -I {} sed -i '/base16scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/flake.nix
if [ $? -ne 0 ]; 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
''

View File

@@ -1,77 +1,76 @@
{ pkgs }:
{pkgs}:
pkgs.writeShellScriptBin "moveonscreen" ''
center_window=false
if [[ $1 == "--center" ]]; then
center_window=true
fi
center_window=false
if [[ $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
''