38 lines
976 B
Plaintext
38 lines
976 B
Plaintext
|
#!/bin/sh
|
||
|
# network module for status/stellar
|
||
|
|
||
|
# values
|
||
|
NETWORK_TRANSMITTED="$(awk '{$1=$1/1024000; print $1"B";}' /sys/class/net/[ew]*/statistics/tx_bytes | sed "s/.*\(....\)/\1/; s|B|B/s |; s/[.]/0./")"
|
||
|
NETWORK_RECEIVED="$(awk '{$1=$1/1024000; print $1"B";}' /sys/class/net/[ew]*/statistics/rx_bytes | sed "s/.*\(....\)/\1/; s|B|B/s |; s/[.]/0./")"
|
||
|
ICON="$1"
|
||
|
BUTTON="$(cat /tmp/speedwm-button)"
|
||
|
|
||
|
case "$TERMINAL" in
|
||
|
"") TERMINAL=st
|
||
|
esac
|
||
|
|
||
|
case "$BUTTON" in
|
||
|
"3") $TERMINAL -e bmon ; exit ;;
|
||
|
esac
|
||
|
|
||
|
# no spacing if there's no icon
|
||
|
if [ "$ICON" != "" ]; then
|
||
|
ICONSPACING=" " # one character spacing
|
||
|
fi
|
||
|
|
||
|
# send the notification
|
||
|
SEND_NOTIF() {
|
||
|
FULL_NETWORK="${ICON}${ICONSPACING}$NETWORK_TRANSMITTED transmitted, $NETWORK_RECEIVED received."
|
||
|
notify-send "$FULL_NETWORK"
|
||
|
|
||
|
echo "Notification sent successfully!"
|
||
|
echo "INFO: $FULL_NETWORK"
|
||
|
|
||
|
exit 0
|
||
|
}
|
||
|
|
||
|
command -v notify-send > /dev/null && SEND_NOTIF
|
||
|
echo "FATAL: libnotify not installed, can't send notification."
|
||
|
|
||
|
exit 1
|