led-config 1011 Bytes
Newer Older
aTc's avatar
aTc committed
1 2
#! /bin/sh

aTc's avatar
aTc committed
3
# bah
aTc's avatar
aTc committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
if [ -e /sys/class/leds/ ] ; then
 
case "$1" in
  start)
	echo "Configuring leds:"
	for led in /sys/class/leds/* ; do
		trigger=$(grep -w "$(basename $led)" /etc/default/leds | awk '{print $2}')
		if [ -n "$trigger" ] ; then
			echo "  $(basename $led): $trigger"
			echo "$trigger" > "$led/trigger"
		fi
	done
;;
  stop)
	echo "Deconfiguring leds:"
	for led in /sys/class/leds/* ; do
		trigger=$(grep -w "$(basename $led)" /etc/default/leds | awk '{print $2}')
		if [ -n "$trigger" ] ; then
			echo "  $(basename $led): no trigger" 
			echo "none" > "$led/trigger"
		fi	
       done
       ;;
aTc's avatar
aTc committed
27 28 29 30 31 32 33 34
  info)
  	echo "Led info:"
  	for led in /sys/class/leds/* ; do
  		trigger=$(cat $led/trigger | cut -d "[" -f2 | cut -d "]" -f1)
  		#trigger=$(cat $led/trigger)
  		echo "$(basename $led)   $trigger"
  	done
  	;;
aTc's avatar
aTc committed
35
  *)
aTc's avatar
aTc committed
36
       echo "Usage: $0 {start|stop|info}"
aTc's avatar
aTc committed
37 38 39 40 41 42 43 44
       exit 1
esac

else
	echo "No LEDs detected"
fi

exit 0