Files
shed/overlay/scripts/wm-controls/chscheme.nix
pagedmov 8c007c3915 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
2024-11-16 03:42:07 -05:00

44 lines
1.5 KiB
Nix
Executable File

{ 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
'';
}