aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/statusbar')
-rwxr-xr-x.local/bin/statusbar/sb-clock18
-rwxr-xr-x.local/bin/statusbar/sb-doppler18
-rwxr-xr-x.local/bin/statusbar/sb-forecast26
-rwxr-xr-x.local/bin/statusbar/sb-internet47
-rwxr-xr-x.local/bin/statusbar/sb-memory20
-rwxr-xr-x.local/bin/statusbar/sb-nettraf23
6 files changed, 73 insertions, 79 deletions
diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock
index 67ad409..a2630fa 100755
--- a/.local/bin/statusbar/sb-clock
+++ b/.local/bin/statusbar/sb-clock
@@ -18,14 +18,12 @@ case "$clock" in
"12") icon="πŸ•›" ;;
esac
-if [ ! -n "$1" ]; then
- date "+%b %d (%a) $icon %H:%M"
-else
- if [ "$1" -eq 1 ]; then
- notify-send "This Month" "$(cal | sed "s/\<$(date +'%e'|tr -d ' ')\>/<b><span color='red'>&<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)"
- elif [ "$1" -eq 3 ]; then
- 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"
- fi
-fi
+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 ;;
+ 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" ;;
+esac
+date "+%Y %b %d (%a) $icon %H:%M"
diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler
index aad82c4..a643407 100755
--- a/.local/bin/statusbar/sb-doppler
+++ b/.local/bin/statusbar/sb-doppler
@@ -4,14 +4,12 @@ showdoppler() {
hyprctl dispatch exec "[float; size 800 800;]" 'curl -s https://meteoinfo.ru/hmc-output/rmap/phenomena.gif | imv - -H 1200 -W 1200'
}
-if [ ! -n "$1" ]; then
- echo πŸŒ…
-else
- if [ "$1" -eq 1 ]; then
- showdoppler
- elif [ "$1" -eq 3 ]; then
- notify-send "πŸ—ΊοΈ Doppler RADAR module" "\- Left click for local Doppler RADAR.
-- You need to manually edit the url in the script to change location."
- fi
-fi
+case $1 in
+ 1) 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" ;;
+esac
+echo πŸŒ…
diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast
index 8b744c4..ebbdf58 100755
--- a/.local/bin/statusbar/sb-forecast
+++ b/.local/bin/statusbar/sb-forecast
@@ -32,25 +32,19 @@ showweather() {
}
openterm() {
- hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "curl wttr.in; read _"'
+ hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "curl wttr.in/Moscow; read _"'
}
-sendnotif() {
- notify-send "🌈 Weather module" "\- Left click for full forecast.
+case $1 in
+ 1) hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "curl wttr.in/Moscow; read _"'
+ ;;
+ 3) notify-send "🌈 Weather module" "\- Left click for full forecast.
- Middle click to update forecast.
β˜”: Chance of rain/snow
πŸ₯Ά: Daily low
-🌞: Daily high"
-}
-
-if [ ! -n "$1" ]; then
- getforecast
- showweather
-else
- if [ "$1" -eq 1 ]; then
- openterm
- elif [ "$1" -eq 3 ]; then
- sendnotif
- fi
-fi
+🌞: Daily high" ;;
+ 6) kitty -e "$EDITOR" "$0" ;;
+esac
+getforecast
+showweather
diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet
index 74a4e28..8f0a3f6 100755
--- a/.local/bin/statusbar/sb-internet
+++ b/.local/bin/statusbar/sb-internet
@@ -4,31 +4,40 @@
# Show 🌐 if connected to ethernet or ❎ if none.
# Show πŸ”’ if a vpn connection is active
-printconnection() {
- [ "$(cat /sys/class/net/eth0/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="❎"
- [ -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ] && tunicon=" πŸ”’"
- printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
+togglevpn() {
+ if [ ! -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ];then
+ doas wg-quick up wg0
+ notify-send "πŸ”’ Internet module" "Connected to VPN"
+ else
+ doas wg-quick down wg0
+ notify-send "πŸ”’ Internet module" "Disconnected from VPN"
+ fi
}
-if [ ! -n "$1" ]; then
- printconnection
-else
- if [ "$1" -eq 1 ]; then
- if [ ! -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ];then
- doas wg-quick up wg0
- notify-send "πŸ”’ Internet module" "Connected to VPN"
- else
- doas wg-quick down wg0
- notify-send "πŸ”’ Internet module" "Disconnected from VPN"
- fi
- elif [ "$1" -eq 3 ]; then
- notify-send "🌐 Internet module" "\- Click to connect
+case $1 in
+ 1) togglevpn 2>/dev/null ;;
+ 3) notify-send "🌐 Internet module" "\- Click to enable/disable VPN
❌: wifi disabled
πŸ“‘: no wifi connection
πŸ“Ά: wifi connection with quality
❎: no ethernet
🌐: ethernet working
πŸ”’: vpn is active
-"
- fi
+" ;;
+ 6) kitty -e "$EDITOR" "$0" ;;
+esac
+
+# Wifi
+if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
+ wifiicon="$(awk '/^\s*w/ { print "πŸ“Ά", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
+elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
+ [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="πŸ“‘ " || wifiicon="❌ "
fi
+
+# Ethernet
+[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="❎"
+
+# Wireguard
+[ -n "$(cat /sys/class/net/wg*/operstate 2>/dev/null)" ] && tunicon=" πŸ”’"
+
+printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory
index a5873ea..5775e76 100755
--- a/.local/bin/statusbar/sb-memory
+++ b/.local/bin/statusbar/sb-memory
@@ -1,17 +1,13 @@
#!/bin/sh
-if [ ! -n "$1" ]; then
- free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
-else
- if [ "$1" -eq 1 ]; then
- notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)"
- elif [ "$1" -eq 2 ]; then
- hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "btop"'
- elif [ "$1" -eq 3 ]; then
- notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
+case $1 in
+ 1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
+ 2) kitty -e sh -c "btop" ;;
+ 3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
- Click to show memory hogs.
-- Middle click to open btop."
- fi
-fi
+- Middle click to open btop." ;;
+ 6) 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-nettraf b/.local/bin/statusbar/sb-nettraf
index c9aa417..92070eb 100755
--- a/.local/bin/statusbar/sb-nettraf
+++ b/.local/bin/statusbar/sb-nettraf
@@ -4,6 +4,13 @@
# transmitted (TX) since the previous time this script ran. So if run every
# second, gives network traffic per second.
+case $1 in
+ 1) kitty -e bmon ;;
+ 3) notify-send "🌐 Network traffic module" "πŸ”»: Traffic received
+πŸ”Ί: Traffic transmitted" ;;
+ 6) kitty -e "$EDITOR" "$0" ;;
+esac
+
update() {
sum=0
for arg; do
@@ -16,15 +23,7 @@ update() {
printf %d\\n $(( sum - old ))
}
-if [ ! -n "$1" ]; then
- rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
- tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
- printf "πŸ”»%4sB πŸ”Ί%4sB\\n" $(numfmt --to=iec $rx $tx)
-else
- if [ "$1" -eq 1 ]; then
- hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "bmon"'
- elif [ "$1" -eq 3 ]; then
- notify-send "🌐 Network traffic module" "πŸ”»: Traffic received
-πŸ”Ί: Traffic transmitted"
- fi
-fi
+rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
+tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
+
+printf "πŸ”»%4sB πŸ”Ί%4sB\\n" $(numfmt --to=iec $rx $tx)