fix(macos): make Alacritty system-theme sync robust

New setup follow-up: ensure activation seeds a writable active-colors file and make theme sync always enforce the current system appearance.

Made-with: Cursor
This commit is contained in:
DannyDannyDanny 2026-03-24 10:19:41 +01:00
parent 82ce5a7fe8
commit f9edde90e4
2 changed files with 10 additions and 7 deletions

View file

@ -150,10 +150,12 @@
# 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"
MOCHA="${../../../assets/alacritty/catppuccin-mocha-colors.toml}"
ACTIVE="${config.xdg.configHome}/alacritty/active-colors.toml"
$DRY_RUN_CMD mkdir -p "${config.xdg.configHome}/alacritty"
if [ ! -f "$ACTIVE" ]; then
$DRY_RUN_CMD cp "$MOCHA" "$ACTIVE"
$DRY_RUN_CMD chmod 0644 "$ACTIVE"
fi
$DRY_RUN_CMD ${pkgs.bash}/bin/bash "${../../../scripts/alacritty-sync-system-theme.sh}" || true
'';

13
scripts/alacritty-sync-system-theme.sh Normal file → Executable file
View file

@ -26,15 +26,16 @@ 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"
tmp="$(mktemp "$ALACRITTY_DIR/active-colors.toml.XXXXXX")"
cp "$LIGHT" "$tmp"
else
cp "$DARK" "$ACTIVE"
tmp="$(mktemp "$ALACRITTY_DIR/active-colors.toml.XXXXXX")"
cp "$DARK" "$tmp"
fi
chmod 0644 "$tmp"
mv -f "$tmp" "$ACTIVE"