feat(macos): Alacritty follows system light/dark appearance
New setup — due for review after you run darwin-rebuild switch and live with it for a few days. See CLAUDE.md (Alacritty) and assets/alacritty/README.md. - HM: import active-colors.toml + Catppuccin latte/mocha fragments - nix-darwin: launchd.user.agents.alacritty-system-theme + PATH helper - fish: background sync on Darwin; theme.sh no longer rebuilds for Alacritty - Remove switch-alacritty-theme.sh (sed + darwin-rebuild per toggle) Made-with: Cursor
This commit is contained in:
parent
18ccebc109
commit
b311e21d5b
15 changed files with 196 additions and 293 deletions
|
|
@ -54,6 +54,10 @@ cd ~/dotfiles/nixos && nix build .#installer-iso
|
||||||
|
|
||||||
Custom nix-darwin module at `nixos/ollama.nix` (upstream PR not yet merged). Enabled on macOS via `nixos/hosts/macos.nix`. Runs as a launchd user agent with `ollama serve`.
|
Custom nix-darwin module at `nixos/ollama.nix` (upstream PR not yet merged). Enabled on macOS via `nixos/hosts/macos.nix`. Runs as a launchd user agent with `ollama serve`.
|
||||||
|
|
||||||
|
## Alacritty (macOS)
|
||||||
|
|
||||||
|
Terminal colors follow **System Settings → Appearance**: `programs.alacritty` imports `~/.config/alacritty/active-colors.toml`; `scripts/alacritty-sync-system-theme.sh` copies Catppuccin latte/mocha there when the OS mode changes. **nix-darwin** `launchd.user.agents.alacritty-system-theme` polls every 30s; **fish** runs the same script on interactive startup. After changing Nix, one `darwin-rebuild switch`. Details: `assets/alacritty/README.md`.
|
||||||
|
|
||||||
## Shell
|
## Shell
|
||||||
|
|
||||||
Fish is the default shell. Bash auto-execs fish unless the parent process is already fish. Vi keybindings with fzf integration. Zoxide aliased to `cd`.
|
Fish is the default shell. Bash auto-execs fish unless the parent process is already fish. Vi keybindings with fzf integration. Zoxide aliased to `cd`.
|
||||||
|
|
|
||||||
|
|
@ -1,102 +1,54 @@
|
||||||
# Unified Theme Switching
|
# Alacritty + system appearance (macOS)
|
||||||
|
|
||||||
Unified theme switching that works across platforms (WSL and macOS) for Neovim, Alacritty, and Windows Terminal.
|
Alacritty follows **System Settings → Appearance** automatically. No `darwin-rebuild` when you change light/dark.
|
||||||
|
|
||||||
**This solution uses a single `theme` command that detects the platform and switches themes appropriately.**
|
## How it works
|
||||||
|
|
||||||
## How It Works
|
1. Home Manager installs Catppuccin palettes as `~/.config/alacritty/catppuccin-{latte,mocha}-colors.toml` and a generated `alacritty.toml` that sets `general.import` to `active-colors.toml`.
|
||||||
|
2. `scripts/alacritty-sync-system-theme.sh` copies the matching palette to `active-colors.toml`. Alacritty’s `live_config_reload` picks it up immediately.
|
||||||
|
3. **nix-darwin** runs that script from a user LaunchAgent every 30s (`nixos/hosts/macos.nix`: `launchd.user.agents.alacritty-system-theme`). It is also installed on `PATH` as `alacritty-sync-system-theme`.
|
||||||
|
4. **Fish** runs the same script in the background when you open an interactive shell on Darwin, so changes apply quickly without waiting for the next poll.
|
||||||
|
|
||||||
1. The `theme` command detects the platform (WSL vs macOS)
|
## Optional manual LaunchAgent
|
||||||
2. **On WSL:** Updates Neovim, Windows Terminal, and Windows system theme
|
|
||||||
3. **On macOS:** Updates Neovim and Alacritty themes via Nix configuration
|
|
||||||
4. Uses the same `nvim_color_scheme` file for Neovim on both platforms
|
|
||||||
|
|
||||||
## Setup
|
If you are not using the nix-darwin agent, you can load `assets/launchd/com.user.alacritty-theme-sync.plist` (adjust paths if needed). **Do not** load both the nix-darwin agent and this plist or you will run two pollers.
|
||||||
|
|
||||||
1. **The configuration is already set up!** The `theme` command is available as a fish alias.
|
If you previously used the old plist label `com.user.alacritty-theme-sync` and switch to nix-darwin only:
|
||||||
|
|
||||||
2. **To switch themes, use the unified command:**
|
|
||||||
```bash
|
|
||||||
theme light # Switch to light theme
|
|
||||||
theme dark # Switch to dark theme
|
|
||||||
theme toggle # Toggle between light and dark themes
|
|
||||||
theme status # Show current theme status
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Unified Theme Command
|
|
||||||
```bash
|
```bash
|
||||||
# Switch to light theme (works on WSL and macOS)
|
launchctl bootout "gui/$(id -u)" ~/Library/LaunchAgents/com.user.alacritty-theme-sync.plist 2>/dev/null || true
|
||||||
theme light
|
```
|
||||||
|
|
||||||
# Switch to dark theme (works on WSL and macOS)
|
## `theme` command (Neovim / WSL)
|
||||||
|
|
||||||
|
The fish alias `theme` still updates `~/.local/share/nvim_color_scheme` (and Windows Terminal on WSL). On macOS, **Alacritty ignores** `theme light|dark` for terminal colors—it only follows System Settings. Neovim stays on whatever you set with `theme`; the Alacritty sync script does not touch the nvim file.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
theme light # Neovim (+ WSL terminal); macOS Alacritty unchanged (uses Appearance)
|
||||||
theme dark
|
theme dark
|
||||||
|
|
||||||
# Toggle between light and dark themes
|
|
||||||
theme toggle
|
theme toggle
|
||||||
|
|
||||||
# Show current theme status
|
|
||||||
theme status
|
theme status
|
||||||
```
|
```
|
||||||
|
|
||||||
### What Gets Updated
|
|
||||||
|
|
||||||
**On WSL:**
|
|
||||||
- Neovim theme (via `~/.local/share/nvim_color_scheme`)
|
|
||||||
- Windows Terminal settings
|
|
||||||
- Windows system theme
|
|
||||||
- Windows sound scheme
|
|
||||||
|
|
||||||
**On macOS:**
|
|
||||||
- Neovim theme (via `~/.local/share/nvim_color_scheme`)
|
|
||||||
- Alacritty theme (via Nix configuration)
|
|
||||||
|
|
||||||
### Manual Configuration (macOS only)
|
|
||||||
You can also manually edit `nixos/home/danny/home.nix` and change:
|
|
||||||
```nix
|
|
||||||
isLightTheme = true; # for light theme
|
|
||||||
isLightTheme = false; # for dark theme
|
|
||||||
```
|
|
||||||
Then run: `cd nixos && sudo darwin-rebuild switch --flake .#Daniel-Macbook-Air`
|
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
|
|
||||||
- `scripts/theme.sh` - **Main unified theme switching script**
|
- `assets/alacritty/catppuccin-latte-colors.toml` / `catppuccin-mocha-colors.toml` — palette fragments
|
||||||
- `scripts/switch-alacritty-theme.sh` - Alacritty-specific theme switching (used by theme.sh)
|
- `scripts/alacritty-sync-system-theme.sh` — detect macOS appearance, copy palette, refresh nvim marker
|
||||||
- `scripts/detect-system-theme.sh` - Detects current macOS system theme (for reference)
|
- `scripts/sync-alacritty-theme.sh` — thin wrapper (backwards compatible)
|
||||||
- `nixos/fish.nix` - Contains the `theme` fish alias
|
- `nixos/home/danny/home.nix` — `programs.alacritty` + `xdg.configFile` for palettes
|
||||||
- `nixos/home/danny/home.nix` - Contains the conditional Alacritty configuration
|
- `nixos/hosts/macos.nix` — LaunchAgent + `alacritty-sync-system-theme` in `environment.systemPackages`
|
||||||
- `bashscripts/wsl_theme.sh` - Legacy WSL script (replaced by theme.sh)
|
- `nixos/fish.nix` — optional shell-open sync on Darwin
|
||||||
|
|
||||||
## Theme Colors
|
After changing Nix config, run `darwin-rebuild switch` once (see repo `AGENTS.md`).
|
||||||
|
|
||||||
|
## Theme colors
|
||||||
|
|
||||||
### Catppuccin Latte (Light)
|
### Catppuccin Latte (Light)
|
||||||
|
|
||||||
- Background: `#eff1f5` (base)
|
- Background: `#eff1f5` (base)
|
||||||
- Foreground: `#4c4f69` (text)
|
- Foreground: `#4c4f69` (text)
|
||||||
- Accent colors optimized for light backgrounds
|
|
||||||
|
|
||||||
### Catppuccin Mocha (Dark)
|
### Catppuccin Mocha (Dark)
|
||||||
|
|
||||||
- Background: `#1e1e2e` (base)
|
- Background: `#1e1e2e` (base)
|
||||||
- Foreground: `#cdd6f4` (text)
|
- Foreground: `#cdd6f4` (text)
|
||||||
- Accent colors optimized for dark backgrounds
|
|
||||||
|
|
||||||
## Integration with NixOS
|
|
||||||
|
|
||||||
The solution uses Nix's conditional configuration in `home.nix`:
|
|
||||||
|
|
||||||
```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
|
|
||||||
29
assets/alacritty/catppuccin-latte-colors.toml
Normal file
29
assets/alacritty/catppuccin-latte-colors.toml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Catppuccin Latte — imported by main alacritty.toml; swapped by sync script.
|
||||||
|
|
||||||
|
[colors.primary]
|
||||||
|
background = "#eff1f5"
|
||||||
|
foreground = "#4c4f69"
|
||||||
|
|
||||||
|
[colors.cursor]
|
||||||
|
text = "#eff1f5"
|
||||||
|
cursor = "#dc8a78"
|
||||||
|
|
||||||
|
[colors.normal]
|
||||||
|
black = "#5c5f77"
|
||||||
|
red = "#d20f39"
|
||||||
|
green = "#40a02b"
|
||||||
|
yellow = "#df8e1d"
|
||||||
|
blue = "#1e40af"
|
||||||
|
magenta = "#ea76cb"
|
||||||
|
cyan = "#179299"
|
||||||
|
white = "#acb0be"
|
||||||
|
|
||||||
|
[colors.bright]
|
||||||
|
black = "#6c6f85"
|
||||||
|
red = "#d20f39"
|
||||||
|
green = "#40a02b"
|
||||||
|
yellow = "#df8e1d"
|
||||||
|
blue = "#1e40af"
|
||||||
|
magenta = "#ea76cb"
|
||||||
|
cyan = "#179299"
|
||||||
|
white = "#bcc0cc"
|
||||||
29
assets/alacritty/catppuccin-mocha-colors.toml
Normal file
29
assets/alacritty/catppuccin-mocha-colors.toml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Catppuccin Mocha — imported by main alacritty.toml; swapped by sync script.
|
||||||
|
|
||||||
|
[colors.primary]
|
||||||
|
background = "#1e1e2e"
|
||||||
|
foreground = "#cdd6f4"
|
||||||
|
|
||||||
|
[colors.cursor]
|
||||||
|
text = "#1e1e2e"
|
||||||
|
cursor = "#f5e0dc"
|
||||||
|
|
||||||
|
[colors.normal]
|
||||||
|
black = "#45475a"
|
||||||
|
red = "#f38ba8"
|
||||||
|
green = "#a6e3a1"
|
||||||
|
yellow = "#f9e2af"
|
||||||
|
blue = "#89b4fa"
|
||||||
|
magenta = "#f5c2e7"
|
||||||
|
cyan = "#94e2d5"
|
||||||
|
white = "#bac2de"
|
||||||
|
|
||||||
|
[colors.bright]
|
||||||
|
black = "#585b70"
|
||||||
|
red = "#f38ba8"
|
||||||
|
green = "#a6e3a1"
|
||||||
|
yellow = "#f9e2af"
|
||||||
|
blue = "#89b4fa"
|
||||||
|
magenta = "#f5c2e7"
|
||||||
|
cyan = "#94e2d5"
|
||||||
|
white = "#a6adc8"
|
||||||
|
|
@ -4,28 +4,18 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>com.user.alacritty-theme-sync</string>
|
<string>com.user.alacritty-theme-sync</string>
|
||||||
|
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>/Users/danny/dotfiles/scripts/sync-alacritty-theme.sh</string>
|
<string>/bin/bash</string>
|
||||||
|
<string>/Users/danny/dotfiles/scripts/alacritty-sync-system-theme.sh</string>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
<key>StartInterval</key>
|
<key>StartInterval</key>
|
||||||
<integer>30</integer>
|
<integer>30</integer>
|
||||||
|
|
||||||
<key>RunAtLoad</key>
|
<key>RunAtLoad</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
|
||||||
<key>StandardOutPath</key>
|
<key>StandardOutPath</key>
|
||||||
<string>/tmp/alacritty-theme-sync.log</string>
|
<string>/tmp/alacritty-theme-sync.log</string>
|
||||||
|
|
||||||
<key>StandardErrorPath</key>
|
<key>StandardErrorPath</key>
|
||||||
<string>/tmp/alacritty-theme-sync-error.log</string>
|
<string>/tmp/alacritty-theme-sync-error.log</string>
|
||||||
|
|
||||||
<key>EnvironmentVariables</key>
|
|
||||||
<dict>
|
|
||||||
<key>PATH</key>
|
|
||||||
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@
|
||||||
|
|
||||||
set fish_greeting 🐟: (set_color yellow; date +%T; set_color green; date --iso-8601 2>/dev/null; or date +%F; set_color normal)
|
set fish_greeting 🐟: (set_color yellow; date +%T; set_color green; date --iso-8601 2>/dev/null; or date +%F; set_color normal)
|
||||||
|
|
||||||
|
# Alacritty palette follows macOS appearance; refresh when opening a shell (LaunchAgent also polls).
|
||||||
|
if test (uname -s) = Darwin
|
||||||
|
bash ~/dotfiles/scripts/alacritty-sync-system-theme.sh >/dev/null 2>&1 &
|
||||||
|
end
|
||||||
|
|
||||||
# name: Default
|
# name: Default
|
||||||
# author: Lily Ballard
|
# author: Lily Ballard
|
||||||
# edits: DannyDannyDanny
|
# edits: DannyDannyDanny
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, lib, zen-browser ? null, ... }:
|
{ pkgs, lib, config, zen-browser ? null, ... }:
|
||||||
{
|
{
|
||||||
# TODO: remove next two lines from here or from flake.nix
|
# TODO: remove next two lines from here or from flake.nix
|
||||||
# home.username = "danny";
|
# home.username = "danny";
|
||||||
|
|
@ -112,15 +112,26 @@
|
||||||
executable = true;
|
executable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Alacritty terminal configuration with conditional theme switching
|
# Palette fragments: synced to system appearance (see scripts/alacritty-sync-system-theme.sh).
|
||||||
|
xdg.configFile."alacritty/catppuccin-latte-colors.toml".source =
|
||||||
|
../../../assets/alacritty/catppuccin-latte-colors.toml;
|
||||||
|
xdg.configFile."alacritty/catppuccin-mocha-colors.toml".source =
|
||||||
|
../../../assets/alacritty/catppuccin-mocha-colors.toml;
|
||||||
|
|
||||||
|
# Alacritty: base config + imported active-colors.toml (updated without rebuild)
|
||||||
programs.alacritty = {
|
programs.alacritty = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
general = {
|
||||||
|
live_config_reload = true;
|
||||||
|
import = [ "${config.xdg.configHome}/alacritty/active-colors.toml" ];
|
||||||
|
};
|
||||||
window = {
|
window = {
|
||||||
padding = { x = 8; y = 8; };
|
padding = { x = 8; y = 8; };
|
||||||
dynamic_padding = true;
|
dynamic_padding = true;
|
||||||
decorations = "buttonless";
|
decorations = "buttonless";
|
||||||
opacity = 0.95;
|
decorations_theme_variant = "None";
|
||||||
|
opacity = 1.0;
|
||||||
startup_mode = "Maximized";
|
startup_mode = "Maximized";
|
||||||
option_as_alt = "Both";
|
option_as_alt = "Both";
|
||||||
};
|
};
|
||||||
|
|
@ -134,43 +145,19 @@
|
||||||
program = "${pkgs.fish}/bin/fish";
|
program = "${pkgs.fish}/bin/fish";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# Conditional colors based on system theme
|
|
||||||
colors = let
|
|
||||||
# Set this to true for light theme, false for dark theme
|
|
||||||
# You can change this and run 'darwin-rebuild switch' to switch themes
|
|
||||||
isLightTheme = true;
|
|
||||||
|
|
||||||
# Catppuccin Latte (Light) colors
|
|
||||||
lightColors = {
|
|
||||||
primary = { background = "0xeff1f5"; foreground = "0x4c4f69"; };
|
|
||||||
cursor = { text = "0xeff1f5"; cursor = "0xdc8a78"; };
|
|
||||||
normal = {
|
|
||||||
black = "0x5c5f77"; red = "0xd20f39"; green = "0x40a02b"; yellow = "0xdf8e1d";
|
|
||||||
blue = "0x1e40af"; magenta = "0xea76cb"; cyan = "0x179299"; white = "0xacb0be";
|
|
||||||
};
|
|
||||||
bright = {
|
|
||||||
black = "0x6c6f85"; red = "0xd20f39"; green = "0x40a02b"; yellow = "0xdf8e1d";
|
|
||||||
blue = "0x1e40af"; magenta = "0xea76cb"; cyan = "0x179299"; white = "0xbcc0cc";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Catppuccin Mocha (Dark) colors
|
|
||||||
darkColors = {
|
|
||||||
primary = { background = "0x1e1e2e"; foreground = "0xcdd6f4"; };
|
|
||||||
cursor = { text = "0x1e1e2e"; cursor = "0xf5e0dc"; };
|
|
||||||
normal = {
|
|
||||||
black = "0x45475a"; red = "0xf38ba8"; green = "0xa6e3a1"; yellow = "0xf9e2af";
|
|
||||||
blue = "0x89b4fa"; magenta = "0xf5c2e7"; cyan = "0x94e2d5"; white = "0xbac2de";
|
|
||||||
};
|
|
||||||
bright = {
|
|
||||||
black = "0x585b70"; red = "0xf38ba8"; green = "0xa6e3a1"; yellow = "0xf9e2af";
|
|
||||||
blue = "0x89b4fa"; magenta = "0xf5c2e7"; cyan = "0x94e2d5"; white = "0xa6adc8";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in if isLightTheme then lightColors else darkColors;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Writable copy (not a symlink to the store — cp in the sync script must replace a real file).
|
||||||
|
home.activation.alacrittySystemTheme = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
|
MOCHA="${config.xdg.configHome}/alacritty/catppuccin-mocha-colors.toml"
|
||||||
|
ACTIVE="${config.xdg.configHome}/alacritty/active-colors.toml"
|
||||||
|
if [ ! -f "$ACTIVE" ]; then
|
||||||
|
$DRY_RUN_CMD cp "$MOCHA" "$ACTIVE"
|
||||||
|
fi
|
||||||
|
$DRY_RUN_CMD ${pkgs.bash}/bin/bash "${../../../scripts/alacritty-sync-system-theme.sh}" || true
|
||||||
|
'';
|
||||||
|
|
||||||
|
|
||||||
# TODO: Put user-installed binaries here if you want HM to own them (optional)
|
# TODO: Put user-installed binaries here if you want HM to own them (optional)
|
||||||
# Fonts
|
# Fonts
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
let
|
||||||
|
alacrittySyncSystemTheme = pkgs.writeShellScriptBin "alacritty-sync-system-theme"
|
||||||
|
(builtins.readFile ../../scripts/alacritty-sync-system-theme.sh);
|
||||||
|
in {
|
||||||
# Apple Silicon + nix-darwin basics
|
# Apple Silicon + nix-darwin basics
|
||||||
nixpkgs.hostPlatform = "aarch64-darwin";
|
nixpkgs.hostPlatform = "aarch64-darwin";
|
||||||
nix.enable = false; # Determinate manages Nix
|
nix.enable = false; # Determinate manages Nix
|
||||||
|
|
@ -48,6 +51,19 @@
|
||||||
# User-specific packages and environment variables are now in home-manager (home.nix)
|
# User-specific packages and environment variables are now in home-manager (home.nix)
|
||||||
# Only system-level packages should remain here if needed
|
# Only system-level packages should remain here if needed
|
||||||
|
|
||||||
|
environment.systemPackages = [ alacrittySyncSystemTheme ];
|
||||||
|
|
||||||
|
# Poll macOS appearance; updates ~/.config/alacritty/active-colors.toml (Alacritty live_config_reload).
|
||||||
|
launchd.user.agents.alacritty-system-theme = {
|
||||||
|
serviceConfig = {
|
||||||
|
RunAtLoad = true;
|
||||||
|
StartInterval = 30;
|
||||||
|
ProgramArguments = [ "${alacrittySyncSystemTheme}/bin/alacritty-sync-system-theme" ];
|
||||||
|
StandardOutPath = "/tmp/alacritty-theme-sync.log";
|
||||||
|
StandardErrorPath = "/tmp/alacritty-theme-sync-error.log";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Keep for darwin as well (tracks defaults across upgrades)
|
# Keep for darwin as well (tracks defaults across upgrades)
|
||||||
# current max per nix-darwin; bump only if a release notes says so
|
# current max per nix-darwin; bump only if a release notes says so
|
||||||
system.stateVersion = 6;
|
system.stateVersion = 6;
|
||||||
|
|
|
||||||
40
scripts/alacritty-sync-system-theme.sh
Normal file
40
scripts/alacritty-sync-system-theme.sh
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Keep Alacritty in sync with macOS light/dark appearance.
|
||||||
|
# No Nix rebuild: copies a palette into active-colors.toml; Alacritty reloads via live_config_reload.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
[[ "$(uname -s)" == "Darwin" ]] || exit 0
|
||||||
|
|
||||||
|
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
|
ALACRITTY_DIR="$XDG_CONFIG_HOME/alacritty"
|
||||||
|
ACTIVE="$ALACRITTY_DIR/active-colors.toml"
|
||||||
|
MARKER="$ALACRITTY_DIR/.last-system-theme"
|
||||||
|
|
||||||
|
LIGHT="$ALACRITTY_DIR/catppuccin-latte-colors.toml"
|
||||||
|
DARK="$ALACRITTY_DIR/catppuccin-mocha-colors.toml"
|
||||||
|
|
||||||
|
if [[ ! -f "$LIGHT" || ! -f "$DARK" ]]; then
|
||||||
|
echo "alacritty-sync-system-theme: missing $LIGHT or $DARK (run home-manager switch first)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
appearance="$(defaults read -g AppleInterfaceStyle 2>/dev/null || true)"
|
||||||
|
if [[ "$appearance" == "Dark" ]]; then
|
||||||
|
want="dark"
|
||||||
|
else
|
||||||
|
want="light"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "$MARKER" ]] && [[ "$(tr -d '\n' <"$MARKER")" == "$want" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$ALACRITTY_DIR"
|
||||||
|
printf '%s' "$want" >"$MARKER"
|
||||||
|
|
||||||
|
if [[ "$want" == "light" ]]; then
|
||||||
|
cp "$LIGHT" "$ACTIVE"
|
||||||
|
else
|
||||||
|
cp "$DARK" "$ACTIVE"
|
||||||
|
fi
|
||||||
|
|
@ -1,27 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# One-shot sync of Alacritty palette + nvim marker from current macOS appearance.
|
||||||
# Simple setup for Alacritty theme synchronization
|
|
||||||
# This creates the theme file and rebuilds the Nix configuration
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Get the directory where this script is located
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
echo "Syncing from system appearance..."
|
||||||
echo "Setting up simple Alacritty theme synchronization..."
|
"$SCRIPT_DIR/alacritty-sync-system-theme.sh"
|
||||||
|
|
||||||
# Run the theme sync script to create the initial theme file
|
|
||||||
echo "Detecting current system theme..."
|
|
||||||
"$SCRIPT_DIR/sync-alacritty-theme.sh"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Setup complete!"
|
echo "Done. Alacritty reloads colors automatically if live_config_reload is enabled."
|
||||||
echo ""
|
echo "A LaunchAgent (nix-darwin: launchd.user.agents.alacritty-system-theme) runs this every 30s."
|
||||||
echo "To apply the theme to Alacritty, run:"
|
|
||||||
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 && 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."
|
|
||||||
|
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
#!/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
|
|
||||||
|
|
@ -1,31 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Back-compat wrapper: sync Alacritty + nvim marker from macOS appearance.
|
||||||
# Sync Alacritty theme with system theme
|
|
||||||
# This script detects the current system theme and updates the theme file that Nix reads
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Get the directory where this script is located
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
exec "$SCRIPT_DIR/alacritty-sync-system-theme.sh"
|
||||||
# Paths
|
|
||||||
THEME_DETECTION_SCRIPT="$SCRIPT_DIR/detect-system-theme.sh"
|
|
||||||
THEME_FILE="/Users/danny/.local/share/nvim_color_scheme"
|
|
||||||
|
|
||||||
# Create the directory if it doesn't exist
|
|
||||||
mkdir -p "$(dirname "$THEME_FILE")"
|
|
||||||
|
|
||||||
# Detect current system theme
|
|
||||||
if [ ! -f "$THEME_DETECTION_SCRIPT" ]; then
|
|
||||||
echo "Error: Theme detection script not found at $THEME_DETECTION_SCRIPT"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
CURRENT_THEME=$("$THEME_DETECTION_SCRIPT")
|
|
||||||
echo "Current system theme: $CURRENT_THEME"
|
|
||||||
|
|
||||||
# Write the theme to the file that Nix reads
|
|
||||||
echo "$CURRENT_THEME" > "$THEME_FILE"
|
|
||||||
|
|
||||||
echo "Theme file updated: $THEME_FILE"
|
|
||||||
echo "Run 'home-manager switch' to apply the new theme to Alacritty"
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ show_usage() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "This command switches themes for:"
|
echo "This command switches themes for:"
|
||||||
echo " - Neovim (via nvim_color_scheme file)"
|
echo " - Neovim (via nvim_color_scheme file)"
|
||||||
echo " - Alacritty (via Nix configuration on macOS)"
|
echo " - Alacritty on macOS follows System Settings (LaunchAgent sync)"
|
||||||
echo " - Windows Terminal (via settings.json on WSL)"
|
echo " - Windows Terminal (via settings.json on WSL)"
|
||||||
echo " - Windows system theme (on WSL)"
|
echo " - Windows system theme (on WSL)"
|
||||||
}
|
}
|
||||||
|
|
@ -43,19 +43,11 @@ show_status() {
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
echo " Platform: macOS"
|
echo " Platform: macOS"
|
||||||
|
|
||||||
# Check Alacritty theme from Nix config
|
marker="$HOME/.config/alacritty/.last-system-theme"
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
if [ -f "$marker" ]; then
|
||||||
DOTFILES_DIR="$(dirname "$SCRIPT_DIR")"
|
echo " Alacritty: follows system (active palette: $(tr -d '\n' <"$marker"))"
|
||||||
HOME_NIX="$DOTFILES_DIR/nixos/home/danny/home.nix"
|
|
||||||
|
|
||||||
if [ -f "$HOME_NIX" ]; then
|
|
||||||
if grep -q "isLightTheme = true" "$HOME_NIX"; then
|
|
||||||
echo " Alacritty: light (Catppuccin Latte)"
|
|
||||||
else
|
|
||||||
echo " Alacritty: dark (Catppuccin Mocha)"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo " Alacritty: config file not found"
|
echo " Alacritty: follows system (sync after next login or run alacritty-sync-system-theme)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " Platform: other"
|
echo " Platform: other"
|
||||||
|
|
@ -67,17 +59,10 @@ toggle_theme() {
|
||||||
current_theme=""
|
current_theme=""
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# On macOS, check the Nix config for current theme
|
if [[ "$(defaults read -g AppleInterfaceStyle 2>/dev/null)" == "Dark" ]]; then
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
current_theme="dark"
|
||||||
DOTFILES_DIR="$(dirname "$SCRIPT_DIR")"
|
else
|
||||||
HOME_NIX="$DOTFILES_DIR/nixos/home/danny/home.nix"
|
current_theme="light"
|
||||||
|
|
||||||
if [ -f "$HOME_NIX" ]; then
|
|
||||||
if grep -q "isLightTheme = true" "$HOME_NIX"; then
|
|
||||||
current_theme="light"
|
|
||||||
else
|
|
||||||
current_theme="dark"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -183,18 +168,8 @@ if [[ -n "$WSL_DISTRO_NAME" ]]; then
|
||||||
powershell.exe -Command "Set-ItemProperty -Path HKCU:\AppEvents\Schemes -Name '(Default)' -Value '.None'"
|
powershell.exe -Command "Set-ItemProperty -Path HKCU:\AppEvents\Schemes -Name '(Default)' -Value '.None'"
|
||||||
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# macOS platform - handle Alacritty theme
|
|
||||||
echo "Detected macOS platform"
|
echo "Detected macOS platform"
|
||||||
|
echo "Alacritty follows System Settings → Appearance (no rebuild). Neovim theme file updated above."
|
||||||
# Use the existing Alacritty theme switching script
|
|
||||||
alacritty_script="$DOTFILES_DIR/scripts/switch-alacritty-theme.sh"
|
|
||||||
if [ -f "$alacritty_script" ]; then
|
|
||||||
echo "Switching Alacritty theme to: $color_scheme"
|
|
||||||
"$alacritty_script" "$color_scheme"
|
|
||||||
else
|
|
||||||
echo "Warning: Alacritty theme script not found at $alacritty_script"
|
|
||||||
echo "Theme file updated, but Alacritty theme not switched"
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Other platforms - just update the theme file
|
# Other platforms - just update the theme file
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue