dotfiles/.local/scripts/bbr/0010_300_weather

23 lines
508 B
Plaintext
Raw Normal View History

2022-10-03 02:06:02 +08:00
#!/bin/bash
2023-03-08 20:06:00 +08:00
CITY="auto"
2022-10-03 02:06:02 +08:00
COLOR1="#AAAAAA"
COLOR2="#444444"
2023-03-08 20:12:41 +08:00
if [ $CITY = "auto" ]
2023-03-08 20:06:00 +08:00
then
2023-03-08 20:12:41 +08:00
CITY="@$(curl -s zx2c4.com/ip | head -1)"
2023-03-08 20:06:00 +08:00
fi
icon=$(curl -s "wttr.in/$CITY?format=%C")
2022-10-03 02:06:02 +08:00
icon=$(echo $icon | tr -d ' ')
temp=$(curl -s "wttr.in/$CITY?format=%t")
2023-03-08 20:28:13 +08:00
wind=$(curl -s https://wttr.in/@178.23.190.182?format=j2 | python3 -c "import sys, json; print(json.load(sys.stdin)['current_condition'][0]['windspeedKmph'])")
2022-10-03 02:06:02 +08:00
2023-03-08 20:28:13 +08:00
echo "^b$COLOR2^^c$COLOR1^ $wind ^b$COLOR1^^c$COLOR2^ $icon ^c$COLOR1^^b$COLOR2^ $temp ^d^"