2.6 KiB
2.6 KiB
Alacritty Theme Synchronization
Simple theme synchronization for Alacritty that automatically switches between Catppuccin light and dark themes based on your macOS system theme.
This solution uses Nix conditional configuration - no complex scripts or wrappers needed!
How It Works
- The system detects your current macOS theme using
defaults read -g AppleInterfaceStyle - The theme is written to
/Users/danny/.local/share/nvim_color_scheme - Your NixOS configuration reads this file and conditionally applies:
- Light theme → Catppuccin Latte
- Dark theme → Catppuccin Mocha
- Alacritty gets the correct theme colors through Nix configuration
Setup
-
Run the setup script:
./scripts/setup-simple-theme-sync.sh -
Apply the theme to Alacritty:
home-manager switch
That's it! Your Alacritty will now use the correct theme based on your system theme.
Usage
Manual Theme Sync
When you change your system theme, run:
./scripts/sync-alacritty-theme.sh && home-manager switch
Automatic Theme Switching (Optional)
For automatic switching, you can set up a LaunchAgent:
cp assets/launchd/com.user.alacritty-theme-sync.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.user.alacritty-theme-sync.plist
Files
scripts/detect-system-theme.sh- Detects current macOS system themescripts/sync-alacritty-theme.sh- Updates the theme file that Nix readsscripts/setup-simple-theme-sync.sh- One-time setup scriptnixos/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
systemThemeFile = "/Users/danny/.local/share/nvim_color_scheme";
isLightTheme = builtins.pathExists systemThemeFile &&
builtins.readFile systemThemeFile == "light\n";
lightColors = { /* Catppuccin Latte colors */ };
darkColors = { /* Catppuccin Mocha colors */ };
in if isLightTheme then lightColors else darkColors;
This approach:
- ✅ Works with Spotlight/Applications folder launches
- ✅ No shell aliases or wrapper scripts needed
- ✅ Integrates cleanly with NixOS configuration
- ✅ Minimal complexity - just 3 simple scripts
- ✅ Uses the same theme file as your Neovim configuration