dotfiles/run_after_kitty-theme-mode.sh
Anton Volnuhin 826a9417e7 kitty: make the theme mode per-machine
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.
2026-08-06 02:03:13 +03:00

26 lines
848 B
Bash
Executable File

#!/bin/sh
# The kitty *-theme.auto.conf files are generated from .config/kitty/themes and
# the per-machine .config/kitty/theme-mode, both of which .chezmoiignore keeps
# out of the source state. Regenerate them here so a freshly applied machine
# ends up with theme files kitty can read.
#
# apply-theme-mode.sh is idempotent, and defaults to `auto` when there is no
# theme-mode file, so a new machine simply follows its OS until told otherwise.
set -eu
config_dir="${KITTY_CONFIG_DIRECTORY:-$HOME/.config/kitty}"
apply="$config_dir/apply-theme-mode.sh"
# Nothing to do on machines without this kitty config applied.
[ -x "$apply" ] || exit 0
[ -d "$config_dir/themes" ] || exit 0
# Never let a theming problem fail the whole apply.
if ! "$apply" "$config_dir"; then
echo "warning: could not regenerate kitty theme files" >&2
fi
exit 0