Skip to content

Instantly share code, notes, and snippets.

@souri
Created January 20, 2017 15:37
Show Gist options
  • Save souri/866a87c39798bc213e50609089cd9d54 to your computer and use it in GitHub Desktop.
Save souri/866a87c39798bc213e50609089cd9d54 to your computer and use it in GitHub Desktop.
Script to use scroll lock led as network indicator for wlan0
#!/bin/bash
# Check interval seconds
CHECKINTERVAL=0.1
# console
CONSOLE=/dev/console
#indicator to use [caps, num, scroll]
INDICATOR=scroll
getNet() {
ifconfig wlan0 | egrep "RX bytes"
}
getVmstat() {
cat /proc/vmstat|egrep "pgpgin|pgpgout"
}
#turn led on
function led_on()
{
#setleds -L +${INDICATOR} < ${CONSOLE}
xset led 3
}
#turn led off
function led_off()
{
#setleds -L -${INDICATOR} < ${CONSOLE}
xset -led 3
}
# initialise variables
NEW=$(getNet)
OLD=$(getNet)
##
while [ 1 ] ; do
sleep $CHECKINTERVAL # slowdown a bit
# get status
NEW=$(getNet)
#compare state
if [ "$NEW" = "$OLD" ]; then
led_off ## no change, led off
else
led_on ## change, led on
fi
OLD=$NEW
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment