chezmoi/dot_config/sway/scripts/executable_weather.sh
kjuulh 9d6cc15469
Add .config/sway/cheatsheet
Add .config/sway/config
Add .config/sway/config.d/application_defaults
Add .config/sway/config.d/autostart_applications
Add .config/sway/config.d/clamshell
Add .config/sway/config.d/default
Add .config/sway/config.d/input
Add .config/sway/config.d/output
Add .config/sway/config.d/theme
Add .config/sway/keyboard.conf
Add .config/sway/scripts/clamshell.sh
Add .config/sway/scripts/import-gsettings
Add .config/sway/scripts/lockman.sh
Add .config/sway/scripts/screenshot.sh
Add .config/sway/scripts/swayfader.py
Add .config/sway/scripts/weather.sh
Add .config/sway/sway.png
Add .config/sway/swaylock.png
2023-07-25 15:39:26 +02:00

16 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=NewYork&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' }'