Skip to content

Instantly share code, notes, and snippets.

@djorborn
Created Apr 14, 2021
Embed
What would you like to do?
Manually Change Brightness In Linux Script
#!/bin/bash
## Very simple way to change brightness without a utility.
## I made this to use with acpi event handlers and my laptop keyboard
## GNU General Public License
## dosborn at vivaldi dot net
# Variables
# brightness_dir= Direcotry containing the backlight file
brightness_dir=/sys/class/backlight/intel_backlight
# brightness_file= the file named brightness in that dir
brightness_file=$brightness_dir/brightness
# brightness= The contents of that file
brightness=$(cat $brightness_file)
# actual_brightness= the actual_brightness file
actual_brightness=$(cat $brightness_dir/actual_brightness)
# max_brightness= the contents of max_brightness
max_brightness=$(cat $brightness_dir/max_brightness)
# min_brightness= how low you want it to get
min_brightness=50
# n= the change, how fast it goes up and down
n=50
## If `brightness_push.sh up` is called then it will go up "n". and 'down' for down.
if [[ "$1" == "up" ]]; then
if (( $actual_brightness < $max_brightness )); then
echo $(dc -e "$actual_brightness $n + p") >> $brightness_file;
fi
else
if (( $actual_brightness > $min_brightness )); then
echo $(dc -e "$actual_brightness $n - p") >> $brightness_file;
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment