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.
This commit is contained in:
parent
74b7f27c06
commit
826a9417e7
@ -10,3 +10,12 @@ Library
|
|||||||
# pi: keep config, never commit secrets/sessions
|
# pi: keep config, never commit secrets/sessions
|
||||||
.pi/agent/auth.json
|
.pi/agent/auth.json
|
||||||
.pi/agent/sessions
|
.pi/agent/sessions
|
||||||
|
|
||||||
|
# kitty: the light/dark mode is per-machine, and the *-theme.auto.conf files
|
||||||
|
# are generated from it plus .config/kitty/themes. Tracking them would make
|
||||||
|
# every machine flag the others' mode. run_after_kitty-theme-mode.sh
|
||||||
|
# regenerates them after apply.
|
||||||
|
.config/kitty/theme-mode
|
||||||
|
.config/kitty/dark-theme.auto.conf
|
||||||
|
.config/kitty/light-theme.auto.conf
|
||||||
|
.config/kitty/no-preference-theme.auto.conf
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
background #1c2836
|
|
||||||
foreground #ffffff
|
|
||||||
cursor #bbbbbb
|
|
||||||
selection_background #b4d5ff
|
|
||||||
color0 #000000
|
|
||||||
color8 #545454
|
|
||||||
color1 #f9555f
|
|
||||||
color9 #fa8b8e
|
|
||||||
color2 #20af89
|
|
||||||
color10 #34bb99
|
|
||||||
color3 #fdf029
|
|
||||||
color11 #ffff55
|
|
||||||
color4 #589cf5
|
|
||||||
color12 #589cf5
|
|
||||||
color5 #934d95
|
|
||||||
color13 #e75598
|
|
||||||
color6 #1e9ee6
|
|
||||||
color14 #3978bb
|
|
||||||
color7 #bbbbbb
|
|
||||||
color15 #ffffff
|
|
||||||
selection_foreground #1c2836
|
|
||||||
|
|
||||||
# START_AUTOGENERATED_TAB_STYLE
|
|
||||||
# Feel free to update these colors manually and remove these comments.
|
|
||||||
active_tab_foreground #1c2836
|
|
||||||
active_tab_background #2e84e6
|
|
||||||
inactive_tab_foreground #2e84e6
|
|
||||||
inactive_tab_background #1c2836
|
|
||||||
# END_AUTOGENERATED_TAB_STYLE
|
|
||||||
|
|
||||||
macos_titlebar_color background
|
|
||||||
@ -54,8 +54,13 @@ for appearance in dark light no-preference; do
|
|||||||
[ -f "$canonical" ] || continue
|
[ -f "$canonical" ] || continue
|
||||||
|
|
||||||
generated="$config_dir/$appearance-theme.auto.conf"
|
generated="$config_dir/$appearance-theme.auto.conf"
|
||||||
|
# stat -f is BSD/macOS, stat -c is GNU; this also runs on Linux boxes.
|
||||||
mode_bits=600
|
mode_bits=600
|
||||||
[ -f "$generated" ] && mode_bits=$(stat -f '%Lp' "$generated")
|
if [ -f "$generated" ]; then
|
||||||
|
mode_bits=$(stat -f '%Lp' "$generated" 2>/dev/null \
|
||||||
|
|| stat -c '%a' "$generated" 2>/dev/null \
|
||||||
|
|| echo 600)
|
||||||
|
fi
|
||||||
|
|
||||||
tmp=$(mktemp "$generated.tmp.XXXXXX")
|
tmp=$(mktemp "$generated.tmp.XXXXXX")
|
||||||
trap 'rm -f "$tmp"' EXIT HUP INT TERM
|
trap 'rm -f "$tmp"' EXIT HUP INT TERM
|
||||||
|
|||||||
@ -22,7 +22,10 @@ for appearance in dark light no-preference; do
|
|||||||
trap 'rm -f "$tmp"' EXIT HUP INT TERM
|
trap 'rm -f "$tmp"' EXIT HUP INT TERM
|
||||||
awk '$1 != "macos_titlebar_color"' "$config_file" > "$tmp"
|
awk '$1 != "macos_titlebar_color"' "$config_file" > "$tmp"
|
||||||
printf '\nmacos_titlebar_color background\n' >> "$tmp"
|
printf '\nmacos_titlebar_color background\n' >> "$tmp"
|
||||||
chmod "$(stat -f '%Lp' "$config_file")" "$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"
|
mv -f "$tmp" "$config_file"
|
||||||
trap - EXIT HUP INT TERM
|
trap - EXIT HUP INT TERM
|
||||||
done
|
done
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
background #1c2836
|
|
||||||
foreground #ffffff
|
|
||||||
cursor #bbbbbb
|
|
||||||
selection_background #b4d5ff
|
|
||||||
color0 #000000
|
|
||||||
color8 #545454
|
|
||||||
color1 #f9555f
|
|
||||||
color9 #fa8b8e
|
|
||||||
color2 #20af89
|
|
||||||
color10 #34bb99
|
|
||||||
color3 #fdf029
|
|
||||||
color11 #ffff55
|
|
||||||
color4 #589cf5
|
|
||||||
color12 #589cf5
|
|
||||||
color5 #934d95
|
|
||||||
color13 #e75598
|
|
||||||
color6 #1e9ee6
|
|
||||||
color14 #3978bb
|
|
||||||
color7 #bbbbbb
|
|
||||||
color15 #ffffff
|
|
||||||
selection_foreground #1c2836
|
|
||||||
|
|
||||||
# START_AUTOGENERATED_TAB_STYLE
|
|
||||||
# Feel free to update these colors manually and remove these comments.
|
|
||||||
active_tab_foreground #1c2836
|
|
||||||
active_tab_background #2e84e6
|
|
||||||
inactive_tab_foreground #2e84e6
|
|
||||||
inactive_tab_background #1c2836
|
|
||||||
# END_AUTOGENERATED_TAB_STYLE
|
|
||||||
|
|
||||||
macos_titlebar_color background
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
background #1c2836
|
|
||||||
foreground #ffffff
|
|
||||||
cursor #bbbbbb
|
|
||||||
selection_background #b4d5ff
|
|
||||||
color0 #000000
|
|
||||||
color8 #545454
|
|
||||||
color1 #f9555f
|
|
||||||
color9 #fa8b8e
|
|
||||||
color2 #20af89
|
|
||||||
color10 #34bb99
|
|
||||||
color3 #fdf029
|
|
||||||
color11 #ffff55
|
|
||||||
color4 #589cf5
|
|
||||||
color12 #589cf5
|
|
||||||
color5 #934d95
|
|
||||||
color13 #e75598
|
|
||||||
color6 #1e9ee6
|
|
||||||
color14 #3978bb
|
|
||||||
color7 #bbbbbb
|
|
||||||
color15 #ffffff
|
|
||||||
selection_foreground #1c2836
|
|
||||||
|
|
||||||
# START_AUTOGENERATED_TAB_STYLE
|
|
||||||
# Feel free to update these colors manually and remove these comments.
|
|
||||||
active_tab_foreground #1c2836
|
|
||||||
active_tab_background #2e84e6
|
|
||||||
inactive_tab_foreground #2e84e6
|
|
||||||
inactive_tab_background #1c2836
|
|
||||||
# END_AUTOGENERATED_TAB_STYLE
|
|
||||||
|
|
||||||
macos_titlebar_color background
|
|
||||||
@ -1 +0,0 @@
|
|||||||
dark
|
|
||||||
25
run_after_kitty-theme-mode.sh
Executable file
25
run_after_kitty-theme-mode.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/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
|
||||||
Loading…
Reference in New Issue
Block a user