From 921ab1773a1945dddac58b52b32000381238c174 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Fri, 23 Apr 2021 23:54:42 -0700 Subject: [PATCH] sxmo_brightness.sh: write brightness val directly to sysfs This removes the dependency on an external compiled app for writing the brightness value to sysfs, and just echoes it directly to the backlight sysfs node. In addition, if the write fails, the script exits instead of sending a misleading notification. Signed-off-by: Stacy Harper --- scripts/core/sxmo_brightness.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/core/sxmo_brightness.sh b/scripts/core/sxmo_brightness.sh index 3128e35..372ac18 100755 --- a/scripts/core/sxmo_brightness.sh +++ b/scripts/core/sxmo_brightness.sh @@ -17,12 +17,14 @@ MINSTEP=1 STEP=$(echo "($MAX - $MIN) / 10" | bc | xargs -ISTP echo -e "$MINSTEP\nSTP" | sort -r | head -n1) setdelta() { - sxmo_setpinebacklight "$( + VAL="$( xargs -IB echo B "$1" < $BACKLIGHT/brightness | bc | xargs -INUM echo -e "$MIN\nNUM" | sort -n | tail -n1 | xargs -INUM echo -e "$MAX\nNUM" | sort -n | head -n1 )" + echo "$VAL" > "$BACKLIGHT/brightness" || exit 1 + echo "set brightness to $VAL" dunstify -i 0 -u normal -r 999 "☀ $(cat $BACKLIGHT/brightness)/${MAX}" }