aboutsummaryrefslogtreecommitdiff
path: root/herbstluftwm/bar/functions/weather
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-12-25 20:28:58 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-12-25 20:28:58 +0530
commitbc13d406e284d5c843a2744c9edc73e522cc0189 (patch)
treef41b13bd175a682ee072d4b81afacc4ce9d7ba9f /herbstluftwm/bar/functions/weather
parent2b1696744fa839f9adf05337e810472c299e3652 (diff)
added a bar for hlwm
Diffstat (limited to 'herbstluftwm/bar/functions/weather')
-rwxr-xr-xherbstluftwm/bar/functions/weather21
1 files changed, 21 insertions, 0 deletions
diff --git a/herbstluftwm/bar/functions/weather b/herbstluftwm/bar/functions/weather
new file mode 100755
index 00000000..df6cf24b
--- /dev/null
+++ b/herbstluftwm/bar/functions/weather
@@ -0,0 +1,21 @@
+#!/bin/zsh
+
+get_current_temp() {
+ if [ $stat = "Smoke" ] || [ $stat = "Sunny" ]; then
+ temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $4 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g")
+ else
+ temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $9 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g")
+ fi
+
+ echo $temp
+}
+
+get_current_weather() {
+ stat=$(curl wttr.in | awk 'NR==3 {print $1}')
+ echo $(get_current_temp)"("$stat")"
+}
+
+while :; do
+ echo $(get_current_weather) > /home/zt/.cache/lemon/weather
+ sleep 3600
+done