aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-forecast
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-27 20:39:10 +0300
committerawy <awy@tutamail.com>2024-08-27 20:39:10 +0300
commit171cb279b05e639f07162059d1d0f390497e36b6 (patch)
tree8a73c16989ac74fe35d40ee0a03f40244dc3e326 /.local/bin/statusbar/sb-forecast
parent65e7d90f0dabd1dc9e0fa3680b4d118189b53d01 (diff)
hyprctl dispatch
Diffstat (limited to '.local/bin/statusbar/sb-forecast')
-rwxr-xr-x.local/bin/statusbar/sb-forecast13
1 files changed, 10 insertions, 3 deletions
diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast
index ebbdf58..113a3ba 100755
--- a/.local/bin/statusbar/sb-forecast
+++ b/.local/bin/statusbar/sb-forecast
@@ -9,6 +9,12 @@ weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
# Get a weather report from 'wttr.in' and save it locally.
getforecast() { timeout --signal=1 2s curl -sf "$url/$LOCATION" > "$weatherreport" || exit 1; }
+# Forecast should be updated only once a day.
+checkforecast() {
+ [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null |
+ cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
+}
+
getprecipchance() {
echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file
grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%'
@@ -36,15 +42,16 @@ openterm() {
}
case $1 in
- 1) hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "curl wttr.in/Moscow; read _"'
+ 1) hyprctl dispatch exec "[float; size 1450 1100;]" "kitty -e less -Sfr \"$weatherreport\""
;;
+ 2) getforecast && showweather ;;
3) notify-send "🌈 Weather module" "\- Left click for full forecast.
- Middle click to update forecast.
☔: Chance of rain/snow
🥶: Daily low
🌞: Daily high" ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
-getforecast
+checkforecast || getforecast
showweather