diff options
Diffstat (limited to '.local/bin/statusbar')
-rwxr-xr-x | .local/bin/statusbar/sb-clock | 18 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-doppler | 18 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-forecast | 26 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-internet | 47 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-memory | 20 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-nettraf | 23 |
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) |