Created
September 24, 2025 20:59
-
-
Save VictorHugoBatista/e39d05db80ea7b9362b9279435644fe6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
| # https://bbs.archlinux.org/viewtopic.php?id=134972 | |
| # How to run: ./brightness.sh -3 #(-3% of brightness) | |
| # base dir for backlight class | |
| basedir="/sys/class/backlight/" | |
| # get the backlight handler | |
| handler=$basedir$(ls $basedir)"/" | |
| # get current brightness | |
| old_brightness=$(cat $handler"brightness") | |
| # get max brightness | |
| max_brightness=$(cat $handler"max_brightness") | |
| # get current brightness % | |
| old_brightness_p=$(( 100 * $old_brightness / $max_brightness )) | |
| # calculate new brightness % | |
| new_brightness_p=$(($old_brightness_p $1)) | |
| # calculate new brightness value | |
| new_brightness=$(( $max_brightness * $new_brightness_p / 100 )) | |
| # set the new brightness value | |
| sudo chmod 666 $handler"brightness" | |
| echo $new_brightness > $handler"brightness" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment