#!/bin/sh # network module for status/stellar # load config . $HOME/.config/speedwm-de/status/config BINDIR="$(dirname $(command -v speedwm_status))/" ARG1="$1" # click CLICK() { # values NETWORK_TRANSMITTED="$(awk '{$ARG1=$ARG1/1024000; print $ARG1"B";}' /sys/class/net/[ew]*/statistics/tx_bytes | sed "s/.*\(....\)/\1/; s|B|B/s |; s/[.]/0./")" NETWORK_RECEIVED="$(awk '{$ARG1=$ARG1/1024000; print $ARG1"B";}' /sys/class/net/[ew]*/statistics/rx_bytes | sed "s/.*\(....\)/\1/; s|B|B/s |; s/[.]/0./")" ICON="$ITEM6_ICON" 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 } # information itself PRINT() { if [ "$ENABLE_ITEM6" = "true" ]; then if [ -e "${BINDIR}awk" ]; then echo "$SEPARATOR $ITEM6_ICON $(awk '{$1=$1/1024000; print $1"B";}' /sys/class/net/[ew]*/statistics/tx_bytes | sed "s/.*\(....\)/\1/; s|B|B/s |; s/[.]/0./")" fi fi } # argument 1 case "$ARG1" in "") CLICK ;; "--print") PRINT > /tmp/module_net ;; "--click") CLICK ;; esac