aboutsummaryrefslogtreecommitdiff
path: root/i3/blocks/weather
diff options
context:
space:
mode:
authorNeodarZ <neodarz@neodarz.ovh>2016-09-21 20:06:02 +0200
committerNeodarZ <neodarz@neodarz.ovh>2016-09-21 20:06:02 +0200
commitf0b7ce9877b22014022ff1a3035a2f3be262b337 (patch)
treea37046f05a746886bb336ec42e8997632cd0aaf9 /i3/blocks/weather
parentafb981f0fe8fa0de77f7451d6907f5094c38f1b5 (diff)
parent78db7d43845d3ea276b8028bec6d67b5a5641a1b (diff)
downloaddotfiles-f0b7ce9877b22014022ff1a3035a2f3be262b337.tar.xz
dotfiles-f0b7ce9877b22014022ff1a3035a2f3be262b337.zip
Ajout de la police awesome
Diffstat (limited to 'i3/blocks/weather')
-rwxr-xr-xi3/blocks/weather55
1 files changed, 55 insertions, 0 deletions
diff --git a/i3/blocks/weather b/i3/blocks/weather
new file mode 100755
index 0000000..4eb3efe
--- /dev/null
+++ b/i3/blocks/weather
@@ -0,0 +1,55 @@
+#!/bin/bash
+# Based on http://openweathermap.org/current
+
+API_KEY="44db6a862fba0b067b1930da0d769e98"
+
+# Check on http://openweathermap.org/find
+CITY_ID="${BLOCK_INSTANCE}"
+
+URGENT_LOWER=0
+URGENT_HIGHER=30
+
+ICON_SUNNY=""
+ICON_CLOUDY=""
+ICON_RAINY=""
+ICON_STORM=""
+ICON_SNOW=""
+ICON_FOG=""
+
+SYMBOL_CELSIUS="℃"
+
+WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
+
+WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
+WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
+WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
+
+if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
+ echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo ""
+elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
+ echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo ""
+elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
+ echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo ""
+elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
+ echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo ""
+elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then
+ echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo ""
+else
+ echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
+ echo ""
+fi
+
+if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then
+ exit 33
+fi