TheRepoClub-DotFiles/lemonbar/.local/bin/lemonbar/lemonbar_network
The-Repo-Club d234b7fe51
Updates
2023-08-19 22:32:45 +01:00

34 lines
909 B
Bash
Executable File

#!/usr/bin/env bash
network() {
R1=$(cat /sys/class/net/wlan0/statistics/rx_bytes)
T1=$(cat /sys/class/net/wlan0/statistics/tx_bytes)
sleep 1
R2=$(cat /sys/class/net/wlan0/statistics/rx_bytes)
T2=$(cat /sys/class/net/wlan0/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