summaryrefslogtreecommitdiff
path: root/write-intel-brightness
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.com>2019-06-29 03:41:17 +0300
committerEvgeny Zinoviev <me@ch1p.com>2019-06-29 03:41:17 +0300
commitb5a8d2b885224ceb765dfdab0297b8e8793b7f68 (patch)
tree0c94d0bf792f1ddd6d279b7339a00ed0801d6818 /write-intel-brightness
first commit
Diffstat (limited to 'write-intel-brightness')
-rwxr-xr-xwrite-intel-brightness36
1 files changed, 36 insertions, 0 deletions
diff --git a/write-intel-brightness b/write-intel-brightness
new file mode 100755
index 0000000..5960144
--- /dev/null
+++ b/write-intel-brightness
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+echoerr() {
+ >&2 echo "$@"
+}
+
+max=$(intel_reg read 0xC8254 2>/dev/null | awk '{print $3}')
+max=${max:2:4}
+max_dec=$(printf "%d" $((16#$max)))
+
+cur_br=$(cat /sys/class/backlight/intel_backlight/brightness)
+cur_per=$(($cur_br * 100 / $max_dec))
+
+case "$1" in
+ "+")
+ new_per=$(($cur_per+10))
+ ;;
+
+ "-")
+ new_per=$(($cur_per-10))
+ ;;
+
+ *)
+ echoerr "command '$1' not supported"
+ exit 1
+ ;;
+esac
+
+if [ $new_per -lt 0 ]; then
+ new_per=0
+elif [ $new_per -gt 100 ]; then
+ new_per=100
+fi
+
+new_val=$(($new_per * $max_dec / 100))
+echo $new_val > /sys/class/backlight/intel_backlight/brightness