`kitten themes` treats every .conf in <config-dir>/themes as a user theme, which the mode system's canonical store was sitting in -- so the picker was offering three bogus entries named light, dark and no-preference, and had been since that store was introduced. Move the store to ./theme-modes so ./themes means only what the kitten means by it, and repoint apply-theme-mode.sh, the kitten shim, the run_after hook and the test at the new path. GrokNight and GrokDay move into ./themes with the ## name/author/ license/upstream/blurb header the kitten reads, so they now show up in `kitten themes` and `--dump-theme` resolves them. theme-modes/dark.conf carries the #202020 theme that was already on disk: the file had to be re-added at its new path, so that drift comes along with it.
61 lines
1.9 KiB
Fish
61 lines
1.9 KiB
Fish
function kitten --description 'Run kitten and restore Kitty theme overrides'
|
|
set -l config_dir "$HOME/.config/kitty"
|
|
if set -q KITTY_CONFIG_DIRECTORY
|
|
set config_dir "$KITTY_CONFIG_DIRECTORY"
|
|
end
|
|
|
|
set -l is_themes false
|
|
if test (count $argv) -gt 0; and test "$argv[1]" = themes
|
|
set is_themes true
|
|
end
|
|
|
|
# The automatic theme files are generated from $config_dir/theme-modes, so record
|
|
# their state first: whichever one the kitten rewrites is the theme just
|
|
# chosen for that appearance, and has to be captured before the mode is
|
|
# re-applied over the top of it.
|
|
set -l appearances dark light no-preference
|
|
set -l before
|
|
if test $is_themes = true
|
|
for appearance in $appearances
|
|
set -l file "$config_dir/$appearance-theme.auto.conf"
|
|
if test -r "$file"
|
|
set -a before (command shasum <"$file" | string split -f1 ' ')
|
|
else
|
|
set -a before missing
|
|
end
|
|
end
|
|
end
|
|
|
|
command kitten $argv
|
|
set -l kitten_status $status
|
|
|
|
if test $kitten_status -eq 0
|
|
and test $is_themes = true
|
|
for index in (seq (count $appearances))
|
|
set -l appearance $appearances[$index]
|
|
set -l file "$config_dir/$appearance-theme.auto.conf"
|
|
test -r "$file"
|
|
or continue
|
|
|
|
set -l now (command shasum <"$file" | string split -f1 ' ')
|
|
test "$now" = "$before[$index]"
|
|
and continue
|
|
|
|
command mkdir -p "$config_dir/theme-modes"
|
|
or return $status
|
|
command cp "$file" "$config_dir/theme-modes/$appearance.conf"
|
|
or return $status
|
|
end
|
|
|
|
"$HOME/.config/kitty/apply-theme-mode.sh" "$config_dir"
|
|
or return $status
|
|
|
|
if set -q KITTY_WINDOW_ID
|
|
command kitty @ load-config
|
|
or return $status
|
|
end
|
|
end
|
|
|
|
return $kitten_status
|
|
end
|