From 7d0c54c7cd0f710fe5d1d3510819f352ec486c23 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 26 Mar 2023 14:01:53 +0200 Subject: Add backlight script --- backlight | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 backlight 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 +# 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" -- cgit v1.2.3