aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2022-11-17 10:56:25 -0800
committerclarkzjw <[email protected]>2022-11-17 10:56:25 -0800
commitd2d735742ca61b211c9b48a2209d36395daebcf4 (patch)
treebda27729a1bbac3ab354a1f10d4885899cdbf967 /dot_config/i3/scripts/executable_openweather-city
parenta6d2e5e6fb9adc84c32e86630b4846b1765c7d77 (diff)
downloaddotfiles-d2d735742ca61b211c9b48a2209d36395daebcf4.tar.gz
+ add existing config
Diffstat (limited to 'dot_config/i3/scripts/executable_openweather-city')
-rw-r--r--dot_config/i3/scripts/executable_openweather-city43
1 files changed, 43 insertions, 0 deletions
diff --git a/dot_config/i3/scripts/executable_openweather-city b/dot_config/i3/scripts/executable_openweather-city
new file mode 100644
index 0000000..6ea051c
--- /dev/null
+++ b/dot_config/i3/scripts/executable_openweather-city
@@ -0,0 +1,43 @@
1#!/usr/bin/env bash
2
3command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed.
4Aborting."; exit 1; }
5command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed.
6Aborting."; exit 1; }
7
8# To use this script you need to create an API key here https://home.openweathermap.org
9# You need to put your Open Weather APIKEY here:
10APIKEY="keykey"
11# find your City ID here: https://openweathermap.org/
12# search for your city and copy the ID from the URL inside the browser.
13CITY_ID="idid"
14URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}"
15
16WEATHER_RESPONSE=$(wget -qO- "${URL}")
17
18WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g')
19WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp')
20WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg')
21WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed')
22
23WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}")
24WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}")
25DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N )
26WIND_DIR=${DIR_ARRAY[WIND_DIR]}
27
28case $WEATHER_CONDITION in
29 'Clouds')
30 WEATHER_ICON=""
31 ;;
32 'Rain')
33 WEATHER_ICON=""
34 ;;
35 'Snow')
36 WEATHER_ICON=""
37 ;;
38 *)
39 WEATHER_ICON=""
40 ;;
41esac
42
43echo "${WEATHER_ICON} ${WEATHER_TEMP}°C: ${WIND_SPEED} km/h ${WIND_DIR}"
Powered by cgit v1.2.3 (git 2.41.0)