formatted nix files using alejandra
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
pkgs,
|
||||
}:
|
||||
pkgs.writeShellScriptBin "splash" ''
|
||||
#!/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
echo "NixOS kernel ver. $(uname -a | awk '{print $3}') x86_64 GNU/Linux"
|
||||
date +"%A %B %-d %Y"
|
||||
echo
|
||||
echo " NixOS" | toilet -f 3d | lolcat -S 25
|
||||
echo "NixOS kernel ver. $(uname -a | awk '{print $3}') x86_64 GNU/Linux"
|
||||
date +"%A %B %-d %Y"
|
||||
echo
|
||||
echo " NixOS" | toilet -f 3d | lolcat -S 25
|
||||
echo
|
||||
''
|
||||
|
||||
@@ -1,83 +1,82 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "toolbelt" ''
|
||||
hostname=$(cat /etc/hostname)
|
||||
hostname=$(cat /etc/hostname)
|
||||
|
||||
cliphistory() {
|
||||
selection=$(cliphist list | fzf --preview="
|
||||
index=\$(echo {} | awk '{print \$1}'); \
|
||||
mime=\$(cliphist decode \$index | file -i -); \
|
||||
if echo \"\$mime\" | grep -q 'image'; then \
|
||||
echo \$(cliphist list | rg \"^\$index\" | cut -d ' ' -f 2- | fmt -w 30); \
|
||||
else \
|
||||
cliphist decode \"\$index\" | fmt -w 30; \
|
||||
fi" --prompt="> " | awk '{print $1}')
|
||||
[ -z "$selection" ] && return 1
|
||||
cliphist decode "$selection" | wl-copy
|
||||
}
|
||||
btop_cmd() {
|
||||
if [ "$hostname" = 'oganesson' ]; then
|
||||
hyprctl dispatch resizeactive 20% 140% &&
|
||||
moveonscreen --center &&
|
||||
btop &&
|
||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||
moveonscreen
|
||||
else
|
||||
hyprctl dispatch resizeactive exact 60% 68% &&
|
||||
moveonscreen --center &&
|
||||
btop &&
|
||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||
moveonscreen
|
||||
fi
|
||||
}
|
||||
cliphistory() {
|
||||
selection=$(cliphist list | fzf --preview="
|
||||
index=\$(echo {} | awk '{print \$1}'); \
|
||||
mime=\$(cliphist decode \$index | file -i -); \
|
||||
if echo \"\$mime\" | grep -q 'image'; then \
|
||||
echo \$(cliphist list | rg \"^\$index\" | cut -d ' ' -f 2- | fmt -w 30); \
|
||||
else \
|
||||
cliphist decode \"\$index\" | fmt -w 30; \
|
||||
fi" --prompt="> " | awk '{print $1}')
|
||||
[ -z "$selection" ] && return 1
|
||||
cliphist decode "$selection" | wl-copy
|
||||
}
|
||||
btop_cmd() {
|
||||
if [ "$hostname" = 'oganesson' ]; then
|
||||
hyprctl dispatch resizeactive 20% 140% &&
|
||||
moveonscreen --center &&
|
||||
btop &&
|
||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||
moveonscreen
|
||||
else
|
||||
hyprctl dispatch resizeactive exact 60% 68% &&
|
||||
moveonscreen --center &&
|
||||
btop &&
|
||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||
moveonscreen
|
||||
fi
|
||||
}
|
||||
|
||||
running=true
|
||||
running=true
|
||||
|
||||
declare -A commands=(
|
||||
["Change Wallpaper"]="moveonscreen --center && if chpaper; then running=false; else moveonscreen; fi"
|
||||
["Change System Color Scheme"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && if chscheme; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
["Open System Monitor"]="hyprctl dispatch resizeactive 20% 140% && moveonscreen --center && btop_cmd && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
||||
["Open Volume Controls"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && alsamixer && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
||||
["Open Keyring"]="hyprctl dispatch resizeactive -300 0 && moveonscreen && if keyring; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
["View Clipboard History"]="hyprctl dispatch resizeactive 45% 120% && moveonscreen --center && if cliphistory;then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
)
|
||||
declare -A commands=(
|
||||
["Change Wallpaper"]="moveonscreen --center && if chpaper; then running=false; else moveonscreen; fi"
|
||||
["Change System Color Scheme"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && if chscheme; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
["Open System Monitor"]="hyprctl dispatch resizeactive 20% 140% && moveonscreen --center && btop_cmd && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
||||
["Open Volume Controls"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && alsamixer && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
||||
["Open Keyring"]="hyprctl dispatch resizeactive -300 0 && moveonscreen && if keyring; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
["View Clipboard History"]="hyprctl dispatch resizeactive 45% 120% && moveonscreen --center && if cliphistory;then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
)
|
||||
|
||||
ordered_commands=(
|
||||
"Open Keyring"
|
||||
"Open System Monitor"
|
||||
"Open Volume Controls"
|
||||
"Change Wallpaper"
|
||||
"Change System Color Scheme"
|
||||
"View Clipboard History"
|
||||
)
|
||||
ordered_commands=(
|
||||
"Open Keyring"
|
||||
"Open System Monitor"
|
||||
"Open Volume Controls"
|
||||
"Change Wallpaper"
|
||||
"Change System Color Scheme"
|
||||
"View Clipboard History"
|
||||
)
|
||||
|
||||
# Use fzf to select a command with preview
|
||||
while $running; do
|
||||
selected_command=$(printf "%s\n" "''${ordered_commands[@]}" | fzf --preview="
|
||||
cleaned_key=\$(echo {} | tr -d \"'\"); \
|
||||
echo \"Cleaned key: \$cleaned_key\"; \
|
||||
declare -A descriptions=(
|
||||
[\"Change Wallpaper\"]=\"Choose a wallpaper to switch to from the assets/wallpapers folder in the system flake directory. Requires rebuilding the system and restarting hyprpaper.\"
|
||||
[\"Change System Color Scheme\"]=\"Changes the base16 color scheme used by stylix to color system applications.\"
|
||||
[\"Open System Monitor\"]=\"Opens a btop window.\"
|
||||
[\"Open Volume Controls\"]=\"Opens alsamixer.\"
|
||||
[\"Open Keyring\"]=\"Opens a fuzzy finder with all of the paths held in ~/.password-store. Selecting one uses pass to copy that password to the clipboard. Password is cleared from clipboard history after 45 seconds.\"
|
||||
[\"View Clipboard History\"]=\"Opens clipboard history. Selecting an item copies it to the clipboard.\"
|
||||
); \
|
||||
if [[ -v descriptions[\$cleaned_key] ]]; then \
|
||||
clear; \
|
||||
echo \''${descriptions[\$cleaned_key]} | fmt -w 28; \
|
||||
else \
|
||||
clear; \
|
||||
echo \"No description available\"; \
|
||||
fi" --prompt="> ")
|
||||
# Use fzf to select a command with preview
|
||||
while $running; do
|
||||
selected_command=$(printf "%s\n" "''${ordered_commands[@]}" | fzf --preview="
|
||||
cleaned_key=\$(echo {} | tr -d \"'\"); \
|
||||
echo \"Cleaned key: \$cleaned_key\"; \
|
||||
declare -A descriptions=(
|
||||
[\"Change Wallpaper\"]=\"Choose a wallpaper to switch to from the assets/wallpapers folder in the system flake directory. Requires rebuilding the system and restarting hyprpaper.\"
|
||||
[\"Change System Color Scheme\"]=\"Changes the base16 color scheme used by stylix to color system applications.\"
|
||||
[\"Open System Monitor\"]=\"Opens a btop window.\"
|
||||
[\"Open Volume Controls\"]=\"Opens alsamixer.\"
|
||||
[\"Open Keyring\"]=\"Opens a fuzzy finder with all of the paths held in ~/.password-store. Selecting one uses pass to copy that password to the clipboard. Password is cleared from clipboard history after 45 seconds.\"
|
||||
[\"View Clipboard History\"]=\"Opens clipboard history. Selecting an item copies it to the clipboard.\"
|
||||
); \
|
||||
if [[ -v descriptions[\$cleaned_key] ]]; then \
|
||||
clear; \
|
||||
echo \''${descriptions[\$cleaned_key]} | fmt -w 28; \
|
||||
else \
|
||||
clear; \
|
||||
echo \"No description available\"; \
|
||||
fi" --prompt="> ")
|
||||
|
||||
|
||||
#Execute the selected command if selection is not empty
|
||||
if [[ -n $selected_command ]]; then
|
||||
eval "''${commands[$selected_command]}"
|
||||
else
|
||||
running=false
|
||||
fi
|
||||
done
|
||||
#Execute the selected command if selection is not empty
|
||||
if [[ -n $selected_command ]]; then
|
||||
eval "''${commands[$selected_command]}"
|
||||
else
|
||||
running=false
|
||||
fi
|
||||
done
|
||||
''
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
pkgs,
|
||||
}:
|
||||
|
||||
{pkgs}:
|
||||
pkgs.writeShellScriptBin "viconf" ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
@@ -41,19 +41,19 @@
|
||||
self = self;
|
||||
pkgs = pkgs;
|
||||
};
|
||||
moveonscreen = import ./wm-controls/moveonscreen.nix { pkgs = pkgs; };
|
||||
toolbelt = import ./commands/toolbelt.nix { pkgs = pkgs; };
|
||||
moveonscreen = import ./wm-controls/moveonscreen.nix {pkgs = pkgs;};
|
||||
toolbelt = import ./commands/toolbelt.nix {pkgs = pkgs;};
|
||||
viconf = import ./commands/viconf.nix {
|
||||
pkgs = pkgs;
|
||||
};
|
||||
chscheme = import ./wm-controls/chscheme.nix {
|
||||
pkgs = pkgs;
|
||||
};
|
||||
chpaper = import ./wm-controls/chpaper.nix { pkgs = pkgs; };
|
||||
chscheme = import ./wm-controls/chscheme.nix {
|
||||
pkgs = pkgs;
|
||||
};
|
||||
chpaper = import ./wm-controls/chpaper.nix {pkgs = pkgs;};
|
||||
in {
|
||||
home.packages = [
|
||||
chpaper
|
||||
chscheme
|
||||
chscheme
|
||||
keyring
|
||||
garbage-collect
|
||||
invoke
|
||||
|
||||
@@ -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
|
||||
''
|
||||
|
||||
@@ -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
|
||||
''
|
||||
|
||||
@@ -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
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user