Skip to content

WestleyK/rpi-brightness

Repository files navigation

A simple command for adjusting your raspberry pi backlight

Designed and tested for raspberry pi with official 7 inch touchscreen.

Other script that do the same thing:



Install, Update and Uninstall

To install:

cd ~/
mkdir raspberrypi-backlight
cd raspberrypi-backlight/
git clone https://github.com/WestleyK/rpi-brightness.git
cd rpi-brightness/
make
sudo make install

Easy install:

Paste or type this in your terminal:

curl https://raw.githubusercontent.com/WestleyK/rpi-backlight/master/easy-install.sh | sh

This will install rpi-brightness to the current directory.

To finish the install, do:

sudo mv rpi-brightness /usr/local/bin/


To update:

cd ~/raspberrypi-backlight/rpi-brightness/
make update
sudo make install


To uninstall:

cd ~/raspberrypi-backlight/rpi-brightness/
sudo make uninstall


Usage:

pi@raspberrypi:~ $ rpi-brightness -help
Usage: rpi-backlight [OPTION]
        -h | -help | --help (print help menu)
        -u | -up (adjust backlight brighter by: 20/255)
        -d | -down (adjust brightness lower by: 20/255)
        -s | -sleep (enter sleep mode, press <ENTER> to exit)
        -c (print current brightness)
        [15-255] (adjust brightness from: 15 to: 255)
        -i | -info (print compiled info)
        -v | -version | --version (print version & date)
Source code: https://github.com/WestleyK/rpi-brightness
pi@raspberrypi:~ $ 

For example, you can do:

sudo rpi-backlight 200

And:

sudo rpi-backlight -sleep

Will enter sleep mode.


Make sure you type sudo before adjusting backlight,
Or you might get this ERROR

pi@raspberrypi:~ $ rpi-brightness -up
ERROR: Brightness file not writable or doesn't exist:
/sys/class/backlight/rpi_backlight/brightness
Try: $ sudo rpi-brightness [OPTION]  (or)  https://github.com/WestleyK/rpi-brightness (for help)
pi@raspberrypi:~ $ 

Don't like the sudo?

If you you don't like typing sudo before adjusting brightness, then
run the no-root.sh script:

sudo ./no-root.sh
sudo reboot

Now you should not need the sudo.

To undo what you did, type:

sudo rm /etc/udev/rules.d/backlight-permissions.rules
sudo reboot


Troubleshooting:

pi@raspberrypi:~ $ rpi-brightness [OPTION]
ERROR: Brightness file not writable.
Try: sudo rpi-brightness  (or)  https://github.com/WestleyK/rpi-brightness (for help)
pi@raspberrypi:~ $ 

Possible causes or fixes:

  • Try sudo and then the command.
  • Try updating.
  • File does't exist.



End README