Created
March 6, 2018 15:16
-
-
Save Everlanders/f3dc236b9d670b105232952592e5e23a to your computer and use it in GitHub Desktop.
Script to Change the Backlight brightness on the Official Raspberry Pi 7" display.
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/bash | |
level=$1 | |
#echo "level given is $level" | |
if [ $# != 1 ]; then | |
echo "USAGE: $0 brightness_level (0 to 255)" | |
exit 1 | |
fi | |
if [[ $level -ge 0 && $level -le 255 ]]; then | |
#echo "level given is $level" | |
echo $level > /sys/class/backlight/rpi_backlight/brightness | |
echo "Screen brightness set to $level." | |
exit 0 | |
else | |
echo "Brightness level $level is out of range! (0 to 255 only)" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 13 gave me a permission denied
i did a little digging and elevated permissions by changing from this:
echo $level > /sys/class/backlight/rpi_backlight/brightness
to this:
sudo sh -c "echo $level > /sys/class/backlight/rpi_backlight/brightness"
Thank you for all your hardwork and research that went into this project