TheRepoClub-DotFiles/lemonbar/.local/bin/lemonbar/lemonbar_weather
2023-08-15 17:37:16 +01:00

33 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
weather() {
configFile=$HOME/.config/repowm/flexiflow_bar/bar_weather.ini
timestamp=$(date +%s)
icon=""
[[ -f $configFile ]] && . $configFile
if [ -z "$LastUsed" ] || [ -z "$Message" ]; then
weather=$(ansiweather | awk '{print $4 $5}')
printf " %s %s \n" "$icon" "$weather"
newtime=$(expr $timestamp + 900)
echo -e "LastUsed=${newtime}\nMessage='${weather}'" >$configFile
else
if [ "$Message" == "weatherdata" ]; then
weather=$(ansiweather | awk '{print $4 $5}')
printf " %s %s \n" "$icon" "$weather"
newtime=$(expr $timestamp + 900)
echo -e "LastUsed=${newtime}\nMessage='${weather}'" >$configFile
else
if [ "$timestamp" -ge "$LastUsed" ]; then
weather=$(ansiweather | awk '{print $4 $5}')
printf " %s %s \n" "$icon" "$weather"
newtime=$(expr $timestamp + 900)
echo -e "LastUsed=${newtime}\nMessage='${weather}'" >$configFile
else
printf " %s %s \n" "$icon" "$Message"
fi
fi
fi
}
weather