blob: fe12b5d627c414d9b499b2f3cb8b86c7bec6023e (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/bash
PROGNAME="$0"
echoerr() {
>&2 echo "error: $@"
}
die() {
echoerr "$@"
exit 1
}
usage() {
cat <<-_EOF
Usage: $PROGNAME +|-
_EOF
exit
}
command_exists() {
command -V "$1" >/dev/null 2>&1
}
[ -z "$1" ] && usage
[ "$EUID" != 0 ] && die "must be run as root"
for c in intel_reg awk; do
if ! command_exists $c; then
die "$c not found"
fi
done
max=$(intel_reg read 0xC8254 2>/dev/null | awk '{print $3}')
max=${max:2:4}
max_dec=$(printf "%d" $((16#$max)))
cur_br=$(cat /sys/class/backlight/intel_backlight/brightness)
cur_per=$(($cur_br * 100 / $max_dec))
case "$1" in
"+")
new_per=$(($cur_per+10))
;;
"-")
new_per=$(($cur_per-10))
;;
*)
echoerr "command '$1' not supported"
exit 1
;;
esac
if [ $new_per -lt 0 ]; then
new_per=0
elif [ $new_per -gt 100 ]; then
new_per=100
fi
new_val=$(($new_per * $max_dec / 100))
echo $new_val > /sys/class/backlight/intel_backlight/brightness
|