power menu, redshift, polybar
This commit is contained in:
30
.config/polybar/scripts/info-airqualityindex/README.md
Normal file
30
.config/polybar/scripts/info-airqualityindex/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Script: info-airqualityindex
|
||||
|
||||
A script that shows the local World Air Quality Index. It's an indicator for the air pollution.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `curl`
|
||||
* `jq`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You need an API token. [Request one](https://aqicn.org/data-platform/token/).
|
||||
|
||||
Choose a city and make sure that the result is what you expect. `berlin` is a valid `CITY` here: http://aqicn.org/city/berlin/. Or use the [map](https://aqicn.org/map/) to find a monitoring station near you. `germany/berlin/friedrichshain-frankfurter-allee` works also as `CITY`.
|
||||
|
||||
If `CITY` is left empty, the location is retrieved via the Mozilla Location API.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-airqualityindex]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-airqualityindex.sh
|
||||
interval = 600
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
TOKEN=""
|
||||
CITY=""
|
||||
|
||||
API="https://api.waqi.info/feed"
|
||||
|
||||
if [ -n "$CITY" ]; then
|
||||
aqi=$(curl -sf "$API/$CITY/?token=$TOKEN")
|
||||
else
|
||||
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
|
||||
|
||||
if [ -n "$location" ]; then
|
||||
location_lat="$(echo "$location" | jq '.location.lat')"
|
||||
location_lon="$(echo "$location" | jq '.location.lng')"
|
||||
|
||||
aqi=$(curl -sf "$API/geo:$location_lat;$location_lon/?token=$TOKEN")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$aqi" ]; then
|
||||
if [ "$(echo "$aqi" | jq -r '.status')" = "ok" ]; then
|
||||
aqi=$(echo "$aqi" | jq '.data.aqi')
|
||||
|
||||
if [ "$aqi" -lt 50 ]; then
|
||||
echo "%{F#009966}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 100 ]; then
|
||||
echo "%{F#ffde33}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 150 ]; then
|
||||
echo "%{F#ff9933}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 200 ]; then
|
||||
echo "%{F#cc0033}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 300 ]; then
|
||||
echo "%{F#660099}#%{F-} $aqi"
|
||||
else
|
||||
echo "%{F#7e0023}#%{F-} $aqi"
|
||||
fi
|
||||
else
|
||||
echo "$aqi" | jq -r '.data'
|
||||
fi
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-airqualityindex/screenshots/1.png
Normal file
BIN
.config/polybar/scripts/info-airqualityindex/screenshots/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user