Skip to content

Instantly share code, notes, and snippets.

@afh
Created June 16, 2016 16:25
Show Gist options
  • Save afh/e518eebdc379d7a1ba3421f4c1589e50 to your computer and use it in GitHub Desktop.
Save afh/e518eebdc379d7a1ba3421f4c1589e50 to your computer and use it in GitHub Desktop.
#!/bin/sh
led_status='/sys/class/leds/chip:white:status'
trigger=''
case $1 in
on) trigger='default-on' ;;
off) trigger='none' ;;
beat) trigger='heartbeat' ;;
charge) trigger='axp20x-usb-online' ;;
blink) trigger='timer'
echo "$trigger" > "$led_status/trigger"
[ ${2:-0} -gt 0 ] && echo $2 > "$led_status/delay_on"
[ ${3:-0} -gt 0 ] && echo $3 > "$led_status/delay_off"
exit 0
;;
*) echo "Unknown LED mode: $1"; exit 1 ;;
esac
echo "$trigger" > "$led_status/trigger"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment