waybar/scripts/weather.py

12 lines
278 B
Python
Raw Normal View History

2024-06-25 21:16:36 +02:00
#!/bin/python3
import requests
import sys
req = requests.get(f'https://wttr.in/{sys.argv[1]}?format="%t:%c:%C"').text[1:-1].split(':')
2024-06-25 21:20:08 +02:00
req[0] = req[0][1:] if req[0][0] == '+' else req[0]
2024-06-25 21:16:36 +02:00
print('{' + f'"text": "{req[0]} {req[1]}", "tooltip": "", "class": "{req[2]}"' + '}')