Display weather status in polybar.
- Python3
- Nerdfonts
Add the following to .../polybar/modules
[module/weather]
type = custom/script
exec = python ~/path/to/polybarWeather.py
And edit the paths to the .json files in polybarWeather.py
if method == 'lat/lon':
with open('your_path/config.json') as file:
config = json.loads(file.read())
latitude = config["lat"]
longitude = config["lon"]
r = getWeatherByLatLon(latitude, longitude)
elif method == 'city/state':
with open('your_path/config.json') as file:
config = json.loads(file.read())
city = urllib.parse.quote(config["city"])
state = urllib.parse.quote(config["state"])
r = getWeatherByCityState(city, state)
else:
print('invalid method')
with open('your_path/weatherIcons.json') as file:
d = json.loads(file.read())
Change parameters in config.json
{"lon": -46.6418, "lat": -23.5587, "city": "Sao Paulo", "state": "sao paulo"}
I've changed the API from openweather to https://documenter.getpostman.com/view/11074732/TzJpizur due to request limits.