replace setpineled C program with a shell script
Signed-off-by: Stacy Harper <contact@stacyharper.net>
This commit is contained in:
parent
5ccfeacfac
commit
ce3f2ea319
6 changed files with 29 additions and 64 deletions
|
@ -6,12 +6,12 @@
|
|||
|
||||
PIDS=""
|
||||
for i in "$@"; do
|
||||
sxmo_setpineled "$i" 150 &
|
||||
sxmo_setpineled.sh "$i" 150 &
|
||||
PIDS="$PIDS $!"
|
||||
done
|
||||
|
||||
echo "$PIDS" | grep -E '[^ ]+' | xargs wait
|
||||
|
||||
for i in "$@"; do
|
||||
sxmo_setpineled "$i" 0
|
||||
sxmo_setpineled.sh "$i" 0
|
||||
done
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
sxmo_setpineled white "$(
|
||||
sxmo_setpineled.sh white "$(
|
||||
grep -qE '^0$' /sys/class/leds/white:flash/brightness &&
|
||||
echo 255 || echo 0
|
||||
)"
|
||||
|
|
23
scripts/core/sxmo_setpineled.sh
Executable file
23
scripts/core/sxmo_setpineled.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
usage () {
|
||||
printf "usage: %s [red|green|blue|white] [0-255]\n" "$0"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# -lt 2 ] && usage
|
||||
|
||||
case $1 in
|
||||
red|green|blue) color="$1"; type="indicator" ;;
|
||||
white) color="$1"; type="flash" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
if [ "$2" -lt 0 ] || [ "$2" -gt 255 ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
brightness="$2"
|
||||
|
||||
printf "%s\n" "$brightness" > "/sys/class/leds/$color:$type/brightness"
|
|
@ -43,10 +43,10 @@ recreateexistingnotifs() {
|
|||
}
|
||||
|
||||
syncled() {
|
||||
sxmo_setpineled green 0
|
||||
sxmo_setpineled.sh green 0
|
||||
if [ "$(find "$NOTIFDIR"/ -type f | wc -l)" -gt 0 ]; then
|
||||
sleep 0.1
|
||||
sxmo_setpineled green 1
|
||||
sxmo_setpineled.sh green 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue