]> git.donarmstrong.com Git - bin.git/commitdiff
add intel_brightness command
authorDon Armstrong <don@donarmstrong.com>
Sat, 24 Sep 2016 21:34:26 +0000 (14:34 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sat, 24 Sep 2016 21:34:26 +0000 (14:34 -0700)
intel_brightness [new file with mode: 0755]

diff --git a/intel_brightness b/intel_brightness
new file mode 100755 (executable)
index 0000000..d67ea65
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ "$(id -u)" != "0" ]; then
+    exec sudo "$0" "$@"
+fi;
+
+MAX=$(cat /sys/class/backlight/intel_backlight/max_brightness)
+CURRENT=$(cat /sys/class/backlight/intel_backlight/brightness)
+NEW=$CURRENT
+ADJ=$(( $MAX  / ${2:-20} ))
+
+if [ "$1" == "max" ]; then
+    NEW=$MAX
+elif [ "$1" == "off" ]; then
+    NEW=0
+elif [ "$1" == "min" ]; then
+    NEW=1
+elif [ "$1" == "dec" ]; then
+    NEW=$(( $CURRENT - $ADJ  < 1 ? 1 : $CURRENT - $ADJ ))
+else
+    NEW=$(( $CURRENT + $ADJ  >= $MAX ? $MAX : $CURRENT + $ADJ ))
+fi
+
+echo $NEW > /sys/class/backlight/intel_backlight/brightness