From 1a5ad084ce055da268f34a9eee2af3691687e580 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:12:07 -0400 Subject: [PATCH] add bash fn to toggle kitty term theme --- bash/.bashrc | 14 ++++++++++++-- kitty/setup.sh | 8 +++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index 225dd90..a07abbf 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -198,8 +198,18 @@ else fi unset color_prompt -# setup kitty -~/.config/kitty/setup.sh +# setup kitty, it will export TERM_COLOR_MODE (can be light or dark) +source ~/.config/kitty/setup.sh +# function to toggle kitty terminal theme +toggle_theme() { + if [ "$TERM_COLOR_MODE" == "light" ]; then + export TERM_COLOR_MODE=dark + kitten @ set-colors --all "$HOME/.config/kitty/dark.conf" + else + export TERM_COLOR_MODE=light + kitten @ set-colors --all "$HOME/.config/kitty/light.conf" + fi +} type -p curl >/dev/null || echo -e "$WARNING curl is not installed" diff --git a/kitty/setup.sh b/kitty/setup.sh index 2297cc8..32d9304 100755 --- a/kitty/setup.sh +++ b/kitty/setup.sh @@ -9,12 +9,14 @@ CURRENT_HOUR=$(date +"%H") SEVEN_AM=7 SEVEN_PM=19 -MODE=dark +TERM_COLOR_MODE=dark if [ $CURRENT_HOUR -ge $SEVEN_AM ] && [ $CURRENT_HOUR -lt $SEVEN_PM ]; then - MODE=light + TERM_COLOR_MODE=light fi -if [ $MODE == "light" ]; then +if [ $TERM_COLOR_MODE == "light" ]; then kitten @ set-colors --all "$HOME/.config/kitty/light.conf" else kitten @ set-colors --all "$HOME/.config/kitty/dark.conf" fi + +export TERM_COLOR_MODE