aboutsummaryrefslogtreecommitdiff
path: root/home/bin/backlight
blob: 553b79a72466c1e306aac3b1f200177d00f2a0ee (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
#!/bin/bash

device=$(find /sys/class/backlight/* -maxdepth 1 | head -n 1)

max=$(cat "$device/max_brightness")
current=$(cat "$device/brightness")
step=20

case "$1" in
    get)
	echo "$current"
	;;
    dec)
	if [[ "$current" -gt 0 ]]; then
	    echo $(( current - step )) > "$device/brightness"
	fi
	;;
    inc)
	if [[ "$current" -lt "$max" ]]; then
	    echo $(( current + step )) > "$device/brightness"
	fi
	;;
    *)
	echo "Unknown argument $1" >&2
	exit 1
	;;
esac