aboutsummaryrefslogtreecommitdiff
path: root/.local
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
parent65e7d90f0dabd1dc9e0fa3680b4d118189b53d01 (diff)
hyprctl dispatch
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/statusbar/sb-clock4
-rwxr-xr-x.local/bin/statusbar/sb-doppler17
-rwxr-xr-x.local/bin/statusbar/sb-forecast13
-rwxr-xr-x.local/bin/statusbar/sb-internet6
-rwxr-xr-x.local/bin/statusbar/sb-memory4
-rwxr-xr-x.local/bin/statusbar/sb-microphone4
-rwxr-xr-x.local/bin/statusbar/sb-nettraf4
-rwxr-xr-x.local/bin/statusbar/sb-volume4
8 files changed, 35 insertions, 21 deletions
diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock
index a2630fa..3e7dd23 100755
--- a/.local/bin/statusbar/sb-clock
+++ b/.local/bin/statusbar/sb-clock
@@ -20,10 +20,10 @@ esac
case $1 in
1) notify-send "This Month" "$(cal | sed "s/\<$(date +'%e'|tr -d ' ')\>/<b><span color='red'>&<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
- 2) kitty -e calcurse ;;
+ 2) hyprctl dispatch exec "kitty -e calcurse" ;;
3) notify-send "πŸ“… Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
- Middle click opens calcurse if installed" ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
date "+%Y %b %d (%a) $icon %H:%M"
diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler
index a643407..a29203a 100755
--- a/.local/bin/statusbar/sb-doppler
+++ b/.local/bin/statusbar/sb-doppler
@@ -1,15 +1,22 @@
#!/bin/sh
-showdoppler() {
- hyprctl dispatch exec "[float; size 800 800;]" 'curl -s https://meteoinfo.ru/hmc-output/rmap/phenomena.gif | imv - -H 1200 -W 1200'
-}
+# Show a Doppler RADAR of a user's preferred location.
+secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds.
+radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar"
+doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif"
+
+getdoppler() { curl -sL https://meteoinfo.ru/hmc-output/rmap/phenomena.gif > "$doppler" ;}
+
+showdoppler() { hyprctl dispatch exec "[float; size 800 800;]" "imv \"$doppler\" -H 1200 -W 1200" ;}
case $1 in
- 1) showdoppler ;;
+ 1) [ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler
+ showdoppler ;;
+ 2) getdoppler && showdoppler ;;
3) notify-send "πŸ—ΊοΈ Doppler RADAR module" "\- Left click for local Doppler RADAR.
- Middle click to update RADAR location.
After $secs seconds, new clicks will also automatically update the doppler RADAR." ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
echo πŸŒ…
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
diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet
index 8f0a3f6..7ba5a0e 100755
--- a/.local/bin/statusbar/sb-internet
+++ b/.local/bin/statusbar/sb-internet
@@ -6,10 +6,10 @@
togglevpn() {
if [ ! -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ];then
- doas wg-quick up wg0
+ doas wg-quick up wg0
notify-send "πŸ”’ Internet module" "Connected to VPN"
else
- doas wg-quick down wg0
+ doas wg-quick down wg0
notify-send "πŸ”’ Internet module" "Disconnected from VPN"
fi
}
@@ -24,7 +24,7 @@ case $1 in
🌐: ethernet working
πŸ”’: vpn is active
" ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
# Wifi
diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory
index 5775e76..45e2701 100755
--- a/.local/bin/statusbar/sb-memory
+++ b/.local/bin/statusbar/sb-memory
@@ -2,11 +2,11 @@
case $1 in
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
- 2) kitty -e sh -c "btop" ;;
+ 2) hyprctl dispatch exec 'kitty -e sh -c "btop"' ;;
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
- Click to show memory hogs.
- Middle click to open btop." ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
diff --git a/.local/bin/statusbar/sb-microphone b/.local/bin/statusbar/sb-microphone
index 339fb78..3b83060 100755
--- a/.local/bin/statusbar/sb-microphone
+++ b/.local/bin/statusbar/sb-microphone
@@ -3,11 +3,11 @@
# Prints the current microphone volume or ο„± if muted.
case $1 in
- 1) kitty -e pulsemixer ;;
+ 1) hyprctl dispatch exec "kitty -e pulsemixer" ;;
3) notify-send "🎀 Microphone volume module" "\- Shows volume πŸŽ™οΈ, ο„± if muted.
- Middle click to mute.
- Scroll to change." ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
vol="$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)"
diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf
index 92070eb..8f2ee77 100755
--- a/.local/bin/statusbar/sb-nettraf
+++ b/.local/bin/statusbar/sb-nettraf
@@ -5,10 +5,10 @@
# second, gives network traffic per second.
case $1 in
- 1) kitty -e bmon ;;
+ 1) hyprctl dispatch exec "kitty -e bmon" ;;
3) notify-send "🌐 Network traffic module" "πŸ”»: Traffic received
πŸ”Ί: Traffic transmitted" ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
update() {
diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume
index ceaface..702742c 100755
--- a/.local/bin/statusbar/sb-volume
+++ b/.local/bin/statusbar/sb-volume
@@ -3,11 +3,11 @@
# Prints the current volume or πŸ”‡ if muted.
case $1 in
- 1) kitty -e pulsemixer ;;
+ 1) hyprctl dispatch exec "kitty -e pulsemixer" ;;
3) notify-send "πŸ“’ Volume module" "\- Shows volume πŸ”Š, πŸ”‡ if muted.
- Middle click to mute.
- Scroll to change." ;;
- 6) kitty -e "$EDITOR" "$0" ;;
+ 6) hyprctl dispatch exec "kitty -e \"$EDITOR\" \"$0\"" ;;
esac
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"