Add hdmi-dimmer.sh
authorColin Patrick Mccabe <cmccabe@alumni.cmu.edu>
Mon, 11 Apr 2016 03:14:59 +0000 (20:14 -0700)
committerColin Patrick Mccabe <cmccabe@alumni.cmu.edu>
Mon, 11 Apr 2016 03:14:59 +0000 (20:14 -0700)
hdmi-dimmer.sh [new file with mode: 0755]

diff --git a/hdmi-dimmer.sh b/hdmi-dimmer.sh
new file mode 100755 (executable)
index 0000000..fae3c1b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+usage() {
+    cat << EOF
+hdmi-dimmer.sh: dims an HDMI screen using xrandr.
+
+usage: hdmi-dimmer.sh [brightness]
+    where brightness is a float from 0.0 to 1.0
+
+example: hdmi-dimmer.sh 0.5
+EOF
+    exit 0
+}
+
+[ $# -lt 1 ] && usage
+BRIGHTNESS="${1}"
+[ "x$BRIGHTNESS" == "x-h" ] && usage
+[ "x$BRIGHTNESS" == "x--help" ] && usage
+
+set -x
+set -e
+xrandr --output HDMI1 --brightness "${BRIGHTNESS}"