Update from current status on citadel
[khome.git] / home / bin / backlight_adjust
CommitLineData
70ece610
SK
1#! /bin/sh
2
3set -e
4
5fun="$1"
6screen_brightness_device_path="/sys/class/backlight/intel_backlight"
7
8# Padding with space because when fun="=10", awk fails to parse fun==10
9new=$(
10 awk -v fun=" $fun" '
11 FILENAME ~ "/max_brightness$" {max = $1; next}
12 FILENAME ~ "/brightness$" {cur = $1; next}
13
14 END {
15 unit = max / 100
16 oper = substr(fun, 2, 1)
17 units = substr(fun, 3, length(fun) - 1)
18 if (oper == "=") {new = unit * units} else
19 if (oper == "+") {new = cur + (unit * units)} else
20 if (oper == "-") {new = cur - (unit * units)} else {
21 printf("Unrecognized operator: %s\n", oper) > "/dev/stderr"
22 exit(1)
23 }
24 print int(new)
25 }
26 ' \
27 "$screen_brightness_device_path/max_brightness" \
28 "$screen_brightness_device_path/brightness"
29)
30
31echo "${new}" | tee "${screen_brightness_device_path}/brightness"
This page took 0.093299 seconds and 4 git commands to generate.