#!/bin/bash
DEV=`nmcli d | grep -P "[^(dis)]connected [^(\(externally\))]" | grep -Po ".*?(?= )" | head -n1`
RX_BYTES=`cat /sys/class/net/$DEV/statistics/rx_bytes`

RX_KB=`expr $RX_BYTES / 1024`
RX_MB=`expr $RX_KB / 1024`

if [ $RX_MB -ge 1 ]
then
    echo $RX_MB mB/s
elif [ $RX_KB >= 1 ]
then
    echo $RX_KB kB/s
else
    echo $RX_BYTES B/s
fi
