m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2023-03-26 14:01:53 +0200
committerMarcin Chrzanowski <m@m-chrzan.xyz>2023-03-26 14:01:53 +0200
commit7d0c54c7cd0f710fe5d1d3510819f352ec486c23 (patch)
treec9ec0910dc2f6e4b3b9e913f50e6f1adf74fd444
parent355d4996dc32988aabe000fbfaa1a9bbdd9ec585 (diff)
Add backlight script
-rwxr-xr-xbacklight26
1 files changed, 26 insertions, 0 deletions
diff --git a/backlight b/backlight
new file mode 100755
index 0000000..2d5e0e2
--- /dev/null
+++ b/backlight
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Allows you to adjust display backlight from the command line.
+# USAGE: backlight <brightness change>
+# The brightness change can be positive (for brighter) or negative (for darker).
+# NOTE: requires root privileges.
+
+brightness=`cat /sys/class/backlight/intel_backlight/brightness`
+delta="$1"
+
+if [[ ! $delta =~ ^-?[0-9]+$ ]]; then
+ echo "Not a number!"
+ exit 1
+fi
+
+new_brightness=$((brightness + delta))
+
+
+if [[ new_brightness -gt 7500 ]]; then
+ new_brightness=7500
+elif [[ new_brightness -lt 0 ]]; then
+ new_brightness=0
+fi
+
+# echo $new_brightness
+tee /sys/class/backlight/intel_backlight/brightness <<< "$new_brightness"