35 lines
1.2 KiB
Bash
Executable File
35 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
mode=$1
|
|
SCRIPTPATH="$HOME/.config/waybar/bar/scripts"
|
|
|
|
if [ "$mode" = "toggle" ]; then
|
|
|
|
if [ "$(bash ${SCRIPTPATH}/waybar_chashfile.sh query '.weather_mode')" = "temp" ]; then
|
|
bash ${SCRIPTPATH}/waybar_chashfile.sh set '.weather_mode="moon"'
|
|
else
|
|
bash ${SCRIPTPATH}/waybar_chashfile.sh set '.weather_mode="temp"'
|
|
fi
|
|
pkill -SIGRTMIN+11 waybar
|
|
echo "pkill 11"
|
|
else
|
|
lastrun=$(bash ${SCRIPTPATH}/waybar_chashfile.sh query '.last_weather_query')
|
|
if [ "$lastrun" = "" ]; then lastrun="0"; fi
|
|
timedelta=$(($(date +%s) - lastrun))
|
|
if [ "$timedelta" -lt 1800 ]; then
|
|
source="local"
|
|
else
|
|
source="online"
|
|
bash ${SCRIPTPATH}/waybar_chashfile.sh set '.last_weather_query=$unixtime' "--arg unixtime "$(date +%s)"" > /dev/null
|
|
fi;
|
|
|
|
main_args=$2
|
|
tooltip_args=$3
|
|
main_args_sec=$4
|
|
tooltip_args_sec=$5
|
|
if [ "$(bash ${SCRIPTPATH}/waybar_chashfile.sh query '.weather_mode')" = "temp" ]; then
|
|
echo "$(bash ${SCRIPTPATH}/curl_wether.sh $source waybar $main_args $tooltip_args)"
|
|
else
|
|
echo "$(bash ${SCRIPTPATH}/curl_wether.sh $source waybar $main_args_sec $tooltip_args_sec)";
|
|
fi
|
|
fi |