sxmo_brightness: add support for overriding backlight device
This uses the BACKLIGHT env var to override the device used for controlling the backlight. My intention was to keep the default behavior if it's unset, use the backlight/backlight path if that exists then fall back to backlight/edp-backlight. Finally, this changes the script to return immediately if no backlight device is found with the given options. Signed-off-by: Stacy Harper <contact@stacyharper.net>
This commit is contained in:
parent
5741f0692c
commit
4c3e6044ce
1 changed files with 9 additions and 5 deletions
|
@ -4,23 +4,27 @@
|
|||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. "$(dirname "$0")/sxmo_common.sh"
|
||||
|
||||
[ -e /sys/class/backlight/edp-backlight ] && DEV=/sys/class/backlight/edp-backlight
|
||||
[ -e /sys/devices/platform/backlight/backlight/backlight ] && DEV=/sys/devices/platform/backlight/backlight/backlight
|
||||
BACKLIGHT="${BACKLIGHT:-/sys/devices/platform/backlight/backlight/backlight}"
|
||||
if [ ! -e "$BACKLIGHT" ] && [ -e /sys/class/backlight/edp-backlight ]; then
|
||||
BACKLIGHT=/sys/class/backlight/edp-backlight
|
||||
fi
|
||||
|
||||
MAX=$(cat $DEV/max_brightness)
|
||||
[ ! -e "$BACKLIGHT" ] && echo "unable to find backlight device" && exit 1
|
||||
|
||||
MAX=$(cat $BACKLIGHT/max_brightness)
|
||||
MIN=2
|
||||
MINSTEP=1
|
||||
STEP=$(echo "($MAX - $MIN) / 10" | bc | xargs -ISTP echo -e "$MINSTEP\nSTP" | sort -r | head -n1)
|
||||
|
||||
setdelta() {
|
||||
sxmo_setpinebacklight "$(
|
||||
xargs -IB echo B "$1" < $DEV/brightness |
|
||||
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
|
||||
)"
|
||||
|
||||
dunstify -i 0 -u normal -r 999 "☀ $(cat $DEV/brightness)/${MAX}"
|
||||
dunstify -i 0 -u normal -r 999 "☀ $(cat $BACKLIGHT/brightness)/${MAX}"
|
||||
}
|
||||
|
||||
up() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue