Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to Change the Backlight brightness on the Official Raspberry Pi 7" display.
#!/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
@sh4un

This comment has been minimized.

sh4un commented Jun 2, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment