blob: d0b8e3b8e7a994dff1225b4e36e04f4f42caaddb (
plain) (
blame)
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
35
|
#!/bin/bash
frac="$1"
if [[ "$frac" == -* ]] ; then
frac=${frac//-}
t='sub'
elif [[ "$frac" == +* ]] ; then
frac=${frac//+}
t='add'
else
t='abs'
fi
max="$(cat /sys/class/backlight/intel_backlight/max_brightness)"
to_set="$(bc <<< "$max * $frac")"
to_set=$(cut -d. -f1 <<< "$to_set") # Cut off the fractional part.
if [[ "$t" == 'sub' ]] ; then
cur="$(cat /sys/class/backlight/intel_backlight/brightness)"
to_set=$((cur - to_set))
elif [[ "$t" == 'add' ]] ; then
cur="$(cat /sys/class/backlight/intel_backlight/brightness)"
to_set=$((cur + to_set))
fi
if [ "$to_set" -gt "$max" ] ; then
to_set="$max"
fi
if [ "$to_set" -lt 0 ] ; then
to_set=0
fi
echo "$to_set" | tee /sys/class/backlight/intel_backlight/brightness
|