~mil/sxmo-utils

ref: dbc3b1ab509aab5f1db72c5cece2ee2a6eb521e8 sxmo-utils/scripts/core/sxmo_brightness.sh -rwxr-xr-x 829 bytes
dbc3b1abStacy Harper Allow the sendnewtextmenu to be used with a number as arg 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env sh

# include common definitions
# 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

MAX=$(cat $DEV/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 |
		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}"
}

up() {
	setdelta "+${STEP}"
}

down() {
	setdelta "-${STEP}"
}

"$@"