Created
April 18, 2021 17:47
-
-
Save zambonin/2b76393a725e289ad43fe6d897b9a8b5 to your computer and use it in GitHub Desktop.
Use the keyboard scroll lock LED as a network activity indicator.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Makefile to turn the keyboard scroll lock LED into a network activity | |
# indicator LED through kernel instrumentation, as documented below. | |
# | |
# https://www.kernel.org/doc/html/latest/leds/index.html | |
# https://www.reddit.com/r/linux/comments/m2kkna/turn_your_keyboard_leds_into_network_indicators/gqjqmx0/ | |
LEDTRIG_MODULE = /lib/modules/$$(uname -r)/kernel/drivers/leds/trigger/ledtrig-netdev.ko.xz | |
SCROLL_LOCK_LED = $(wildcard /sys/class/leds/input*::scrolllock) | |
NETWORK_INTERFACE = $(shell ip -br addr | awk '/UP/ { print $$1 }') | |
on: | |
modprobe ledtrig-netdev | |
echo "netdev" | tee $(SCROLL_LOCK_LED)/trigger >/dev/null | |
echo "1" | tee $(SCROLL_LOCK_LED)/rx >/dev/null | |
echo "1" | tee $(SCROLL_LOCK_LED)/tx >/dev/null | |
echo $(NETWORK_INTERFACE) | tee $(SCROLL_LOCK_LED)/device_name >/dev/null | |
off: | |
echo "kbd-scrolllock" | tee $(SCROLL_LOCK_LED)/trigger >/dev/null | |
modprobe -r ledtrig-netdev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment