3 # A very primitive backlight setter with a hardcoded backlight path, to replace
4 # xbacklight which currently does not work on my system.
6 if ! echo "${1}" | egrep -q '^[0-9]+$' && ! [ "${1}" = "+" -o "${1}" = "-" ]; then
7 echo 'Argument must be a number, or "+", or "-".'
10 backlight_dir=/sys/class/backlight/intel_backlight
11 max_brightness=$(cat "${backlight_dir}"/max_brightness)
12 target="${backlight_dir}"/brightness
13 fract=$(expr "${max_brightness}" / 100)
14 if [ "${1}" = "+" -o "${1}" = "-" ]; then
15 cur_brightness=$(cat "${backlight_dir}"/brightness)
16 brightness=$(expr "${cur_brightness}" "${1}" "${fract}")
17 if [ "${brightness}" -gt "${max_brightness}" ]; then
18 brightness="${max_brightness}"
19 elif [ "${brightness}" -lt "0" ]; then
22 sudo sh -c 'echo '"${brightness}"' > '"${target}"
26 if [ "${percentage}" = '100' ]; then
27 sudo sh -c 'echo '"${max_brightness}"' > '"${target}"
29 brightness=$(expr "${percentage}" \* "${fract}")
30 sudo sh -c 'echo '"${brightness}"' > '"${target}"