summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/i3weather
diff options
context:
space:
mode:
authorVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:30:52 +0530
committerVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:30:52 +0530
commit5c916d69d457101326803eb076a746060e3618cf (patch)
treed6fce3256eede1c1bf78fb6a1be75b9cc4b84cee /.local/bin/statusbar/i3weather
Moved from github
Diffstat (limited to '.local/bin/statusbar/i3weather')
-rwxr-xr-x.local/bin/statusbar/i3weather26
1 files changed, 26 insertions, 0 deletions
diff --git a/.local/bin/statusbar/i3weather b/.local/bin/statusbar/i3weather
new file mode 100755
index 0000000..2d34149
--- /dev/null
+++ b/.local/bin/statusbar/i3weather
@@ -0,0 +1,26 @@
+#!/bin/sh
+# i3block for displaying the current temperature, humidity and precipitation, if wttr.in i unavailable then WEATHER UNAVAILABLE will be displayed
+
+case "$BLOCK_BUTTON" in
+ '') ;;
+ 1)
+ $TERMINAL -e less -r ~/.cache/weather.txt & sleep 0.3
+ i3-msg 'move to workspace "12: Weather"; workspace "12: Weather"' >/dev/null 2>&1
+ ;;
+ 2) $TERMINAL -e nvim "$0" ;;
+ *) notify-send "⛅ Refreshing weather info..." ;;
+esac
+
+HTTP_WEATHER="https://wttr.in/Vasai"
+# weather="$(curl -s "$HTTP_WEATHER?format=%c%C++❄️+%t++☀️+%f++🌬️+%w")"
+weather="$(curl -Ss "$HTTP_WEATHER?0&T&Q" | cut -c 16- | head -2 |
+ xargs echo "$(curl -s "$HTTP_WEATHER?format=%c")")"
+
+if [ "$(echo "$weather" | grep -Ec "(Unknown|curl|HTML)")" -gt 0 ]; then
+ echo "WEATHER UNAVAILABLE"
+else
+ echo "${weather:-⛅ -- }"
+fi
+
+curl -s "$HTTP_WEATHER" > ~/.cache/weather.txt
+