Last active
May 23, 2023 18:58
-
-
Save atilberk/38c13eda1f0d4874ca2dd453ee1c2a68 to your computer and use it in GitHub Desktop.
A simple shell script for Ubuntu to adjust screen brightness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: | |
# sh /path/to/adjust_brightness.sh [up|down|<an integer between 0-100>] | |
# Requires the change of ownership of the baclight file to the user | |
# Run this once to change the ownership: | |
# "sudo chown $(whoami):$(whoami) /sys/class/backlight/intel_backlight/brightness" | |
# You can then assign keyboard shortcuts to adjust brightness. For example, | |
# "sh /path/to/adjust_brightness.sh up" -> "CTRL + B" | |
# "sh /path/to/adjust_brightness.sh down" -> "CTRL + N" | |
command=$1 | |
brightness="/sys/class/backlight/intel_backlight/brightness" | |
max_brightness="/sys/class/backlight/intel_backlight/max_brightness" | |
if [ "$command" = "up" ]; then | |
echo $(( $(cat $backlight) + $(cat $max_brightness) / 10 )) | tee $backlight | |
elif [ "$command" = "down" ]; then | |
echo $(( $(cat $backlight) - $(cat $max_brightness) / 10 )) | tee $backlight | |
else | |
echo $(( $1 * $(cat $max_brightness) / 100)) | tee $backlight | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
best script ever, i have been using it for years now :) many thx