Last active
December 22, 2017 18:09
-
-
Save pwittchen/6eda564ad3a71ca1d57ffc28c0bd7aef to your computer and use it in GitHub Desktop.
This script is responsible for getting Common Air Quality Index (CAQI) in Poland basing on airly.eu sensors. It works with BitBar on macOS and Argos on Linux with Gnome 3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script is responsible for getting Common Air Quality Index (CAQI) in Poland basing on airly.eu sensors | |
# Replace API_KEY with your key, YOUR_LATITUDE and YOUR_LONGITUDE with your location | |
# get your API key at: https://developer.airly.eu/ | |
# this script can be used with bitbar on macOS: https://github.com/matryer/bitbar | |
# and argos on Linux with Gnome 3: https://github.com/p-e-w/argos | |
# requirements: curl and jq (on Linux it works just with jq - on macOS I needed to add /usr/local/bin/jq) | |
CAQI=$(curl -s -X GET --header 'Accept: application/json' --header 'apikey: YOUR_API_KEY' \ | |
'https://airapi.airly.eu/v1/nearestSensor/measurements?latitude=YOUR_LATITUDE&longitude=YOUR_LONGITUDE&maxDistance=1000' \ | |
| /usr/local/bin/jq .airQualityIndex | cut -f1 -d".") | |
MSG="Unknown" | |
case 1 in | |
$(($CAQI <= 25))) MSG="Great!";; | |
$(($CAQI <= 50))) MSG="Good!";; | |
$(($CAQI <= 75))) MSG="Medium";; | |
$(($CAQI <= 100))) MSG="Bad";; | |
$(($CAQI >= 101))) MSG="Very Bad";; | |
esac | |
echo "CAQI: $CAQI ($MSG)" | |
# info about Common Air Quality Index (CAQI) in Poland | |
# https://www.airqualitynow.eu/pl/about_indices_definition.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment