From db24cbafa58db5b7deb427932582e9e2c62eba09 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:10:05 -0400 Subject: [PATCH] change theme just using set times --- kitty/setup.sh | 57 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) diff --git a/kitty/setup.sh b/kitty/setup.sh index e4e1bbc..2297cc8 100755 --- a/kitty/setup.sh +++ b/kitty/setup.sh @@ -5,61 +5,12 @@ if [ "$OS" = "Linux" ]; then kitten @ set-font-size --all 11.0 fi -# get the SUNRISE/SUNSET time for the day -DATE_FILE=$HOME/.config/kitty/date_output.txt -CURRENT_DATE=$(date +"%B %d") -LOCATION=c5326b3950212c71c67cee42b213313f555df223d9668aabb44c6719dc67685c -TMP_FILE=$HOME/.config/kitty/$LOCATION.html -SUNRISE_CACHE=$HOME/.config/kitty/$LOCATION.SUNRISE -SUNSET_CACHE=$HOME/.config/kitty/$LOCATION.SUNSET - -time_to_minutes() { - local time=$1 - local hours=${time%:*} - local minutes=${time#*:} - echo $((10#$hours * 60 + 10#$minutes)) -} - -get_sunrise_sunset() { - wget -q "https://weather.com/weather/today/l/$LOCATION" -O "$TMP_FILE" - - SUNR=$(rg SunriseSunset "$TMP_FILE" | rg -o '((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))' | head -1) - SUNS=$(rg SunriseSunset "$TMP_FILE" | rg -o '((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))' | tail -1) - echo $SUNR - echo $SUNS - - SUNRISE=$(date --date="$SUNR" +%R) - SUNSET=$(date --date="$SUNS" +%R) - echo $SUNRISE - echo $SUNSET - - echo "$SUNRISE" > $SUNRISE_CACHE - echo "$SUNSET" > $SUNSET_CACHE -} - -get_sunrise_sunset_from_cache() { - read -r SUNRISE < $SUNRISE_CACHE - read -r SUNSET < $SUNSET_CACHE -} - -if [ -f "$DATE_FILE" ]; then - STORED_DATE=$(bat "$DATE_FILE") - if [ "$STORED_DATE" != "$CURRENT_DATE" ]; then - echo "$CURRENT_DATE" > "$DATE_FILE" - get_sunrise_sunset - else - get_sunrise_sunset_from_cache - fi -else - echo "$CURRENT_DATE" > "$DATE_FILE" - get_sunrise_sunset -fi +CURRENT_HOUR=$(date +"%H") +SEVEN_AM=7 +SEVEN_PM=19 MODE=dark -NOW=$(date +"%H%M") -SUNRISE_MINUTES=${SUNRISE/':'/} -SUNSET_MINUTES=${SUNSET/':'/} -if [ $NOW -ge $SUNRISE_MINUTES ] && [ $NOW -lt $SUNSET_MINUTES ]; then +if [ $CURRENT_HOUR -ge $SEVEN_AM ] && [ $CURRENT_HOUR -lt $SEVEN_PM ]; then MODE=light fi if [ $MODE == "light" ]; then