summaryrefslogtreecommitdiff
path: root/scripts/slight
blob: 0289ff4f5e88eb45b20da27ecbda4bc4e3c75b68 (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
#!/bin/sh

. slib

help() {
cat << EOF
${0}: Wrapper script to change backlight
options:
 -i [Brg]        Increase backlight by Brg
 -d [Brg]        Decrease backlight by Brg
 -s [Brg]        Set backlight to Brg
 -p              Show the current backlight
 -h              Print this message and exit

NOTE: Script interprets values as percentages
EOF

exit 0
}

check_program "brightnessctl"

[ ${#} != 1 ] && [ ${#} != 2 ] && invalid_use

while getopts "i:d:s:ph" option; do
	case "${option}" in
	i) run --reload-status "brightnessctl set +${OPTARG}%" ;;

	d) run --reload-status "brightnessctl set ${OPTARG}-%" ;;

	s) run --reload-status "brightnessctl set ${OPTARG}%" ;;

	p)
		if ! echo $(( ($(brightnessctl g) * 100)  / $(brightnessctl m) )); then
			err "Failed to get current brightness"
		else
			exit 0
		fi
	;;
	h) help ;;

	*) invalid_use -h ;;

	esac
done

# Unreachable
invalid_use