TheRepoClub-DotFiles/lemonbar/.local/bin/lemonbar/lemonbar_network
The-Repo-Club 7c1fbc918e
Update Dotfiles
Signed-off-by: The-Repo-Club <wayne6324@gmail.com>
2022-10-16 15:14:37 +01:00

35 lines
972 B
Bash
Executable File

#!/usr/bin/env bash
network() {
R1=`cat /sys/class/net/wlp0s20f3/statistics/rx_bytes`
T1=`cat /sys/class/net/wlp0s20f3/statistics/tx_bytes`
sleep 1
R2=`cat /sys/class/net/wlp0s20f3/statistics/rx_bytes`
T2=`cat /sys/class/net/wlp0s20f3/statistics/tx_bytes`
TBPS=`expr $T2 - $T1`
RBPS=`expr $R2 - $R1`
TKBPS=`echo "$TBPS / 1024"| bc`
RKBPS=`echo "$RBPS / 1024"| bc`
icon_up=" ﯴ"
icon_down=" ﯲ"
if [ "$RKBPS" -gt "1024" ]; then
RKBPS=`echo "scale=2; $RKBPS / 1024"| bc`
RKBPS=" $RKBPS mb"
else
RKBPS=" $RKBPS kb"
fi
if [ "$TKBPS" -gt "1024" ]; then
TKBPS=`echo "scale=2; $TKBPS / 1024"| bc`
TKBPS=" $TKBPS mb"
else
TKBPS=" $TKBPS kb"
fi
printf "%s%s%s%s\n" "%{F#1e222a}%{B#BE78D1}$icon_down %{F-}%{B-}" "%{F#1e222a}%{B#C4C7C5}${RKBPS} %{F-}%{B-}" "%{F#1e222a}%{B#BE78D1}$icon_up %{F-}%{B-}" "%{F#1e222a}%{B#C4C7C5}${TKBPS} %{F-}%{B-}"
}
network