From 4a4bc5ad4e868ab8235aae32ee35823d34ec7799 Mon Sep 17 00:00:00 2001 From: awy Date: Tue, 27 Aug 2024 18:33:41 +0300 Subject: more convenient / original way --- .config/waybar/config | 17 ++++++++++----- .local/bin/statusbar/sb-clock | 18 +++++++-------- .local/bin/statusbar/sb-doppler | 18 +++++++-------- .local/bin/statusbar/sb-forecast | 26 +++++++++------------- .local/bin/statusbar/sb-internet | 47 ++++++++++++++++++++++++---------------- .local/bin/statusbar/sb-memory | 20 +++++++---------- .local/bin/statusbar/sb-nettraf | 23 ++++++++++---------- 7 files changed, 85 insertions(+), 84 deletions(-) diff --git a/.config/waybar/config b/.config/waybar/config index 0fd19e5..4c0b071 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -28,7 +28,8 @@ "interval": 10, "on-click": "sb-memory 1", "on-click-right": "sb-memory 3", - "on-click-middle": "sb-memory 2" + "on-click-middle": "sb-memory 2", + "on-click-backward": "sb-memory 6", }, "custom/doppler" : { @@ -38,7 +39,8 @@ "exec" : "sb-doppler", "on-click": "sb-doppler 1", "on-click-right": "sb-doppler 3", - "on-click-middle": "pkill -RTMIN+13 waybar" + "on-click-middle": "pkill -RTMIN+13 waybar", + "on-click-backward": "sb-doppler 6" }, "custom/forecast" : { @@ -49,7 +51,8 @@ "interval" : 1800, "on-click": "sb-forecast 1", "on-click-right": "sb-forecast 3", - "on-click-middle": "pkill -RTMIN+5 waybar" + "on-click-middle": "pkill -RTMIN+5 waybar", + "on-click-backward": "sb-forecast 6" }, "custom/nettraf" : { @@ -59,7 +62,8 @@ "exec" : "sb-nettraf", "interval" : 1, "on-click": "sb-nettraf 1", - "on-click-right": "sb-nettraf 3" + "on-click-right": "sb-nettraf 3", + "on-click-backward": "sb-nettraf 6" }, "custom/microphone" : { @@ -91,7 +95,9 @@ "exec" : "sb-clock", "interval" : 60, "on-click": "sb-clock 1", + "on-click-middle": "sb-clock 2", "on-click-right": "sb-clock 3", + "on-click-backward": "sb-clock 6", }, "custom/internet" : { @@ -101,6 +107,7 @@ "exec" : "sb-internet", "on-click": "sb-internet 1; pkill -RTMIN+4 waybar", "on-click-right": "sb-internet 3; pkill -RTMIN+4 waybar", - "on-click-middle": "pkill -RTMIN+4 waybar" + "on-click-middle": "pkill -RTMIN+4 waybar", + "on-click-backward": "sb-internet 6" } } 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 ' ')\>/&<\/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 ' ')\>/&<\/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) -- cgit v1.2.3