From 1e20a2223bb8a30b450ef90826f5a53e185f659f Mon Sep 17 00:00:00 2001 From: Maxim Karasev Date: Tue, 31 Aug 2021 17:33:58 +0300 Subject: [PATCH] Rename sxmo_setpineled.sh to sxmo_setled.sh, add bq-paella support Signed-off-by: Stacy Harper --- scripts/core/sxmo_blinkled.sh | 4 +-- scripts/core/sxmo_flashtoggle.sh | 2 +- scripts/core/sxmo_setled.sh | 29 +++++++++++++++++++ scripts/core/sxmo_setpineled.sh | 23 --------------- .../notifications/sxmo_notificationmonitor.sh | 4 +-- 5 files changed, 34 insertions(+), 28 deletions(-) create mode 100755 scripts/core/sxmo_setled.sh delete mode 100755 scripts/core/sxmo_setpineled.sh diff --git a/scripts/core/sxmo_blinkled.sh b/scripts/core/sxmo_blinkled.sh index 36cee37..e150345 100755 --- a/scripts/core/sxmo_blinkled.sh +++ b/scripts/core/sxmo_blinkled.sh @@ -6,12 +6,12 @@ PIDS="" for i in "$@"; do - sxmo_setpineled.sh "$i" 150 & + sxmo_setled.sh "$i" 150 & PIDS="$PIDS $!" done echo "$PIDS" | grep -E '[^ ]+' | xargs wait for i in "$@"; do - sxmo_setpineled.sh "$i" 0 + sxmo_setled.sh "$i" 0 done diff --git a/scripts/core/sxmo_flashtoggle.sh b/scripts/core/sxmo_flashtoggle.sh index 101922b..821e053 100755 --- a/scripts/core/sxmo_flashtoggle.sh +++ b/scripts/core/sxmo_flashtoggle.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh -sxmo_setpineled.sh white "$( +sxmo_setled.sh white "$( grep -qE '^0$' /sys/class/leds/white:flash/brightness && echo 255 || echo 0 )" diff --git a/scripts/core/sxmo_setled.sh b/scripts/core/sxmo_setled.sh new file mode 100755 index 0000000..4cf73bc --- /dev/null +++ b/scripts/core/sxmo_setled.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +usage () { + printf "usage: %s [red|green|blue|white] [0-255]\n" "$0" + exit 1 +} + +[ $# -lt 2 ] && usage + +case "$(cut -d, -f2 < /sys/firmware/devicetree/base/compatible)" in + l8910qcom) # bq-paella + color="white"; type="kbd_backlight";; + *) # assume pinephone/pinetab + case $1 in + red|green|blue) color="$1"; type="indicator" ;; + white) color="$1"; type="flash" ;; + *) usage ;; + esac + ;; +esac + +if [ "$2" -lt 0 ] || [ "$2" -gt 255 ] +then + usage +fi + +brightness="$2" + +printf "%s\n" "$brightness" > "/sys/class/leds/$color:$type/brightness" diff --git a/scripts/core/sxmo_setpineled.sh b/scripts/core/sxmo_setpineled.sh deleted file mode 100755 index 70729c0..0000000 --- a/scripts/core/sxmo_setpineled.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/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" diff --git a/scripts/notifications/sxmo_notificationmonitor.sh b/scripts/notifications/sxmo_notificationmonitor.sh index 4e3ff54..020e5e3 100755 --- a/scripts/notifications/sxmo_notificationmonitor.sh +++ b/scripts/notifications/sxmo_notificationmonitor.sh @@ -43,10 +43,10 @@ recreateexistingnotifs() { } syncled() { - sxmo_setpineled.sh green 0 + sxmo_setled.sh green 0 if [ "$(find "$NOTIFDIR"/ -type f | wc -l)" -gt 0 ]; then sleep 0.1 - sxmo_setpineled.sh green 1 + sxmo_setled.sh green 1 fi }