2021-04-30 15:59:22 +02:00
|
|
|
#!/usr/bin/env bash
|
2021-04-10 05:35:06 +02:00
|
|
|
|
|
|
|
INTERVAL="1" # update interval in seconds
|
|
|
|
|
2021-09-13 23:00:18 +02:00
|
|
|
network_name=$(tmux show-option -gqv "@dracula-network-bandwidth")
|
2021-04-10 05:35:06 +02:00
|
|
|
|
|
|
|
main() {
|
|
|
|
while true
|
2021-07-06 10:22:36 +02:00
|
|
|
do
|
|
|
|
initial_download=$(cat /sys/class/net/$network_name/statistics/rx_bytes)
|
|
|
|
initial_upload=$(cat /sys/class/net/$network_name/statistics/tx_bytes)
|
|
|
|
|
|
|
|
sleep $INTERVAL
|
|
|
|
|
|
|
|
final_download=$(cat /sys/class/net/$network_name/statistics/rx_bytes)
|
|
|
|
final_upload=$(cat /sys/class/net/$network_name/statistics/tx_bytes)
|
|
|
|
|
|
|
|
total_download_bps=$(expr $final_download - $initial_download)
|
|
|
|
total_upload_bps=$(expr $final_upload - $initial_upload)
|
|
|
|
|
|
|
|
total_download_kbps=$(echo "scale=2; $total_download_bps / 1024" | bc)
|
|
|
|
total_upload_kbps=$(echo "scale=2; $total_upload_bps / 1024" | bc)
|
|
|
|
|
|
|
|
echo "↓ $total_download_kbps kB/s • ↑ $total_upload_kbps kB/s"
|
|
|
|
done
|
2021-04-10 05:35:06 +02:00
|
|
|
}
|
|
|
|
main
|