2.6 KiB
2.6 KiB
Alacritty Theme Synchronization
Simple theme switching for Alacritty that allows you to switch between Catppuccin light and dark themes.
This solution uses Nix conditional configuration with a simple script to switch themes.
How It Works
- The Nix configuration has a boolean variable
isLightThemeinhome.nix - When
isLightTheme = true→ Catppuccin Latte (light theme) - When
isLightTheme = false→ Catppuccin Mocha (dark theme) - A script updates this variable and rebuilds the configuration
Setup
-
The configuration is already set up! Your Alacritty is currently using the light theme.
-
To switch themes, use the script:
./scripts/switch-alacritty-theme.sh light # Switch to light theme ./scripts/switch-alacritty-theme.sh dark # Switch to dark theme ./scripts/switch-alacritty-theme.sh toggle # Toggle between themes ./scripts/switch-alacritty-theme.sh status # Show current theme
Usage
Manual Theme Switching
# Switch to light theme
./scripts/switch-alacritty-theme.sh light
# Switch to dark theme
./scripts/switch-alacritty-theme.sh dark
# Toggle between themes
./scripts/switch-alacritty-theme.sh toggle
# Check current theme
./scripts/switch-alacritty-theme.sh status
Manual Configuration
You can also manually edit nixos/home/danny/home.nix and change:
isLightTheme = true; # for light theme
isLightTheme = false; # for dark theme
Then run: cd nixos && sudo darwin-rebuild switch --flake .#Daniel-Macbook-Air
Files
scripts/switch-alacritty-theme.sh- Script to switch themesscripts/detect-system-theme.sh- Detects current macOS system theme (for reference)nixos/home/danny/home.nix- Contains the conditional Alacritty configuration
Theme Colors
Catppuccin Latte (Light)
- Background:
#eff1f5(base) - Foreground:
#4c4f69(text) - Accent colors optimized for light backgrounds
Catppuccin Mocha (Dark)
- Background:
#1e1e2e(base) - Foreground:
#cdd6f4(text) - Accent colors optimized for dark backgrounds
Integration with NixOS
The solution uses Nix's conditional configuration in home.nix:
colors = let
isLightTheme = true; # Change this to switch themes
lightColors = { /* Catppuccin Latte colors */ };
darkColors = { /* Catppuccin Mocha colors */ };
in if isLightTheme then lightColors else darkColors;
This approach:
- ✅ Works with Spotlight/Applications folder launches
- ✅ No complex file reading or external dependencies
- ✅ Integrates cleanly with NixOS configuration
- ✅ Simple and reliable - just change a boolean and rebuild
- ✅ Easy to understand and maintain