From ea722302ac0cec6279200f65789193b978fe983a Mon Sep 17 00:00:00 2001 From: jornmann Date: Sat, 9 Apr 2022 18:25:55 +0300 Subject: [PATCH] add upload and download speed modules --- config.sh | 2 ++ modules.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/config.sh b/config.sh index d47794d..b7d8534 100755 --- a/config.sh +++ b/config.sh @@ -20,4 +20,6 @@ #module_cpu "CPU: " " | " #module_battery "Battery: " " | " #module_todo "TODO: " " | " +#module_upload "Up: " " | " +#module_download "Down: " " | " module_date "Date: " "" diff --git a/modules.sh b/modules.sh index 8b606e0..a7ed9ea 100755 --- a/modules.sh +++ b/modules.sh @@ -59,3 +59,17 @@ module_todo() { todooutput="$(head -n 1 ~/.todo.txt)" [ "$todooutput" = "" ] || export bar="${bar}${1}${todooutput}${2}" } + +export netdevice="" + +module_upload() { + # https://github.com/speediegamer/xshbar-plugins/blob/main/netstat.plugin + up="$(cat /sys/class/net/${netdevice}/statistics/rx_bytes | awk '{$1=$1/1024000; print $1"B";}' | tail -n 1)" + export bar="${bar}${1}${up}${2}" +} + +module_download() { + # https://github.com/speediegamer/xshbar-plugins/blob/main/netstat.plugin + down="$(cat /sys/class/net/${netdevice}/statistics/tx_bytes | awk '{$1=$1/1024000; print $1"B";}' | tail -n 1)" + export bar="${bar}${1}${down}${2}" +}