Page 1 of 1

RPi Touch Display -- Brightness Control via Menu & Desktop Icons

Posted: Tue Aug 20, 2019 5:32 am
by mikeKeY
I love this little display & didn't want to bake it (or my eyeballs) with full-power backlighting.
To adjust brightness, the gain-elevated-privileges & type lotsa stuff method became really old.

By creating a few .desktop files, pre-set brightness levels can be set via the Menu.
They're handy on the Desktop too (especially when using a virtual keyboard), but be mindful of the security implications with this approach.

Create files that resemble the following & place them within /usr/share/applications.
SU privileges are required to access this folder & file ownership should be root:root, with permissions something like 0644.
"Name" below is what'll appear on Menu | Settings; In this case "Screen-17". The File Name can be the same, but with the .desktop suffix.

[Desktop Entry]
Name = Screen-17
GenericName = Touchscreen 17/255
Comment = Dim 17 / 255
Keywords = Touchscreen;Dim;Brightness;
TryExec = su-to-root
Exec = su-to-root -X -c 'echo "17" > /sys/class/backlight/rpi_backlight/brightness'
StartupNotify = false
Terminal = false
Type = Application
Icon = /usr/share/icons/Lightbulbs/bulb20-256x256.png
Categories = Settings;X-Xfce-Toplevel;
NoDisplay = false

Seventeen happens to be a brightness level that I use frequently -- Create several files with integer values that work for you.
Note that an icon is required, but that the one specified is non-standard. Grab or create your own icons & place them within /usr/share/icons.
These'll be "fixed" & won't change as you hop from PiX to Tango, etc. Mine are segregated into a sub-folder named Lightbulbs.

I'm a big fan of DIY, but if you're truly averse to typing, the files can be found here:
https://github.com/MikeKY/Raspberry-Tou ... ss-Buttons

Happy Tinkering !