feat: introduce script for manual theme switching in Alacritty and update README for clarity

This commit is contained in:
DannyDannyDanny 2025-09-12 13:33:33 +02:00
parent d7302fd9a6
commit c8a7e3fb34
4 changed files with 121 additions and 40 deletions

View file

@ -18,10 +18,10 @@ echo ""
echo "Setup complete!"
echo ""
echo "To apply the theme to Alacritty, run:"
echo " home-manager switch"
echo " cd nixos && sudo darwin-rebuild switch --flake .#Daniel-Macbook-Air"
echo ""
echo "To sync themes when your system theme changes:"
echo " $SCRIPT_DIR/sync-alacritty-theme.sh && home-manager switch"
echo " $SCRIPT_DIR/sync-alacritty-theme.sh && cd nixos && sudo darwin-rebuild switch --flake .#Daniel-Macbook-Air"
echo ""
echo "For automatic theme switching, you can set up a LaunchAgent or"
echo "run the sync script manually when needed."

View file

@ -0,0 +1,80 @@
#!/bin/bash
# Switch Alacritty theme by updating the Nix configuration
# This script changes the isLightTheme variable in home.nix and rebuilds
set -e
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOTFILES_DIR="$(dirname "$SCRIPT_DIR")"
HOME_NIX="$DOTFILES_DIR/nixos/home/danny/home.nix"
# Check if home.nix exists
if [ ! -f "$HOME_NIX" ]; then
echo "Error: home.nix not found at $HOME_NIX"
exit 1
fi
# Function to switch to light theme
switch_to_light() {
echo "Switching to light theme (Catppuccin Latte)..."
sed -i '' 's/isLightTheme = false;/isLightTheme = true;/' "$HOME_NIX"
}
# Function to switch to dark theme
switch_to_dark() {
echo "Switching to dark theme (Catppuccin Mocha)..."
sed -i '' 's/isLightTheme = true;/isLightTheme = false;/' "$HOME_NIX"
}
# Function to show current theme
show_current() {
if grep -q "isLightTheme = true" "$HOME_NIX"; then
echo "Current theme: Light (Catppuccin Latte)"
else
echo "Current theme: Dark (Catppuccin Mocha)"
fi
}
# Function to rebuild the configuration
rebuild() {
echo "Rebuilding configuration..."
cd "$DOTFILES_DIR/nixos"
sudo darwin-rebuild switch --flake .#Daniel-Macbook-Air
}
# Main logic
case "${1:-}" in
"light")
switch_to_light
rebuild
;;
"dark")
switch_to_dark
rebuild
;;
"toggle")
if grep -q "isLightTheme = true" "$HOME_NIX"; then
switch_to_dark
else
switch_to_light
fi
rebuild
;;
"status"|"current")
show_current
;;
*)
echo "Usage: $0 {light|dark|toggle|status}"
echo ""
echo "Commands:"
echo " light - Switch to light theme (Catppuccin Latte)"
echo " dark - Switch to dark theme (Catppuccin Mocha)"
echo " toggle - Toggle between light and dark themes"
echo " status - Show current theme"
echo ""
show_current
exit 1
;;
esac