summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xwrocwttr16
1 files changed, 9 insertions, 7 deletions
diff --git a/wrocwttr b/wrocwttr
index 4aa5b3a..dccb1cc 100755
--- a/wrocwttr
+++ b/wrocwttr
@@ -1,12 +1,14 @@
#!/bin/sh
+# Check the temperature in Wrocław, Poland
-# export DISPLAY=:0.0
-# export HOME=/home/filipek
+CITY="Wroc%C5%82aw"
+CACHE_DIR="$HOME/.cache/weather"
+FILE="$CACHE_DIR/wroc.txt"
-# ł is URL-encoded
-temp=$(curl "wttr.in/Wroc%C5%82aw?format=1" | awk '{print $2}')
-file="$HOME/.cache/weather/wroc.txt"
+mkdir -p "$CACHE_DIR"
+
+temp="$(curl -fsS --max-time 5 -A "wrocwttr/1.0" \
+ "https://wttr.in/$CITY?format=%t")" || exit 1
[ -z "$temp" ] && exit 1
-echo "$temp" > "$file"
-# notify-send "Temperature updated."
+echo "$temp" > "$FILE"