change theme just using set times
This commit is contained in:
parent
5f79d906f6
commit
db24cbafa5
1 changed files with 4 additions and 53 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue