chezmoi/dot_config/waybar/scripts/executable_weather.sh
kjuulh b3a17d2abd
Add .config/waybar/config
Add .config/waybar/scripts/PBPbattery.sh
Add .config/waybar/scripts/keyhint.sh
Add .config/waybar/scripts/power-menu.sh
Add .config/waybar/scripts/weather.sh
Add .config/waybar/style.css
2023-07-28 13:14:56 +02:00

14 lines
577 B
Bash

#!/bin/bash
LOC="$1"
# HTML encode string as %20
LOCATION=$(sed -e "s/ /%20/g" <<<"$LOC")
content=$(curl -sS "https://thisdavej.azurewebsites.net/api/weather/current?loc=$LOCATION&deg=C")
ICON=$(curl -s 'https://wttr.in/?format=1' | sed 's/[+0-9a-cA-Z°-]//g' )
# echo $ICON
TEMP=$(echo $content | jq -r '. | "\(.temperature)°\(.degType)"' | sed 's/"//g')
TOOLTIP=$(echo $content | jq -r '. | "\(.temperature)°\(.degType)\n\(.skytext)"' | sed 's/"//g')
CLASS=$(echo $content | jq .skytext)
echo '{"text": "'$TEMP'", "tooltip": "'$ICON $TOOLTIP $LOC'", "class": '$CLASS' }'