theme-mode is a per-machine preference, and the three *-theme.auto.conf files are generated from it plus themes/, so tracking any of them made every machine flag the others' choice. Drop all four from the source state and ignore them. That leaves a freshly applied machine with no theme files for kitty to read, so add run_after_kitty-theme-mode.sh to regenerate them from the canonical themes. It defaults to `auto`, so a new machine follows its OS until told otherwise, and it exits quietly where this kitty config isn't applied rather than failing the run. Since that script now runs on every apply, including on Linux, make the permission lookup in both shell scripts fall back from BSD `stat -f` to GNU `stat -c` and then to 600.
32 lines
947 B
Bash
32 lines
947 B
Bash
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
config_dir=${1:-"$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"}
|
|
|
|
for appearance in dark light no-preference; do
|
|
config_file="$config_dir/$appearance-theme.auto.conf"
|
|
[ -f "$config_file" ] || continue
|
|
|
|
if awk '
|
|
$1 == "macos_titlebar_color" {
|
|
count++
|
|
if ($2 == "background") correct++
|
|
}
|
|
END { exit !(count == 1 && correct == 1) }
|
|
' "$config_file"; then
|
|
continue
|
|
fi
|
|
|
|
tmp=$(mktemp "$config_file.tmp.XXXXXX")
|
|
trap 'rm -f "$tmp"' EXIT HUP INT TERM
|
|
awk '$1 != "macos_titlebar_color"' "$config_file" > "$tmp"
|
|
printf '\nmacos_titlebar_color background\n' >> "$tmp"
|
|
# stat -f is BSD/macOS, stat -c is GNU; this also runs on Linux boxes.
|
|
chmod "$(stat -f '%Lp' "$config_file" 2>/dev/null \
|
|
|| stat -c '%a' "$config_file" 2>/dev/null \
|
|
|| echo 600)" "$tmp"
|
|
mv -f "$tmp" "$config_file"
|
|
trap - EXIT HUP INT TERM
|
|
done
|