blob: b79e68058381995515d8b1a21f57a85a091a08f2 (
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
|
#!/bin/sh
set -e
backlight_sys_dir="/sys/class/backlight/intel_backlight"
read -r max_brightness < "${backlight_sys_dir}/max_brightness"
read -r curr_brightness < "${backlight_sys_dir}/brightness"
if ! groups | grep -q backlight; then
echo "User is not in the backlight group"
exit 1
fi
if [ "$#" -eq 0 ] ; then
# set to half that of 'max_brightness'
echo $((max_brightness / 2)) > "$backlight_sys_dir"/brightness
exit 0
fi
case "$1" in
up) increment="+ 10" ;;
down) increment="- 10" ;;
*) exit 1 ;;
esac
new_brightness=$(($curr_brightness $increment))
if $((new_brightness < 1)) || $((new_brightness > $max_brightness)); then
exit 1
else
echo "$new_brightness" > "$backlight_sys_dir"/brightness
fi
|