aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-nettraf
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-27 18:33:41 +0300
committerawy <awy@tutamail.com>2024-08-27 18:33:41 +0300
commit4a4bc5ad4e868ab8235aae32ee35823d34ec7799 (patch)
tree12a3777396a03bb9601e823e3e36db9af0c04684 /.local/bin/statusbar/sb-nettraf
parent2c0341950bdee4f1aa8bdb6e71f64c73f84cdc80 (diff)
more convenient / original way
Diffstat (limited to '.local/bin/statusbar/sb-nettraf')
-rwxr-xr-x.local/bin/statusbar/sb-nettraf23
1 files changed, 11 insertions, 12 deletions
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)