#!/bin/bash blink() { time=$1 delay=$2 for i in $(seq 1 $time) do echo 1 > /sys/class/leds/input$INPUT::capslock/brightness echo 1 > /sys/class/leds/input$INPUT::scrolllock/brightness echo 1 > /sys/class/leds/input$INPUT::numlock/brightness sleep $delay echo 0 > /sys/class/leds/input$INPUT::capslock/brightness echo 0 > /sys/class/leds/input$INPUT::scrolllock/brightness echo 0 > /sys/class/leds/input$INPUT::numlock/brightness sleep $delay done } INPUT=$(ls /sys/class/leds/ | grep input[^0] | cut -d ':' -f 1 | sed 's/input//g' | head -n 1) if [[ ! -n $INPUT ]]; then echo "You woot?" exit 1 fi logger "lucine started on input $INPUT" blink 2 1 pipe="/tmp/lucine" trap "rm -rf $pipe" EXIT if [[ ! -p $pipe ]]; then mkfifo $pipe chmod 666 $pipe fi while : do if read line <$pipe; then command=$(echo $line | cut -f 1 -d ' ') case $command in blink) time=$(echo $line | cut -f 2 -d ' ') delay=$(echo $line | cut -f 3 -d ' ') blink $time $delay ;; quit) break; ;; *) ;; esac fi done