Adjusting the backlighting of screens on your laptop/notebook or all-in-one computers should 'just work' in many of the well known desktop environments such as:

1. Unity IconsPage/ubuntu.png

2. Gnome

3. KDE IconsPage/kubuntu.png


With the constant and ever changing designs of display hardware along with the evolving architecture of the Linux kernel -- occasionally, the adjustment of the screen backlight will fail using in-built methods. And, if you are using a standalone window manager without a desktop environment such as Openbox, then -- you are often left without a method to do so built-in to the keyboard grabbing code of the underlying system to begin with.


Since the beginning of hardware abstracted video display technology, such as the Xorg server, a challenge for the software developers of operating system's has been to provide 'discoverable' methods for users to control the graphics hardware of their computer systems. In particular, with the advent of laptops/notebooks and all-in-one desktops, the control of backlighting the screen has gradually and seemingly totally moved away from hardware controls to that of software in the video sub-system. Our operating systems must now issue the commands that were once the job of BIOS firmware in conjunction with hardware keys or buttons. The methods for doing this in software have become varied and ever-changing over the past few years. We must trust that our /sys/ directories will populate with the correct /class/backlight/ entries and that when they do, ... our OS will know how to manipulate them.


If your Linux boot scripts are able to probe and load the correct drivers for the video hardware that is responsible for adjusting backlighting then you probably would not be reading this right now. And so ... if the desktop environment is not able to adjust the lighting or if you are using a standalone window manager, then -- here is a script that, when properly adjusted for the intended system, might just work:

Use your preferred editor(gedit | nano | vi | emacs)

$ sudo vi /usr/local/bin/sysbacklight

Then copy/paste the following script into your new file and customize it:


# backlight brightness controls. use freely
# and adjust sysfs directory to your backlight type. 
# $author Brice Burgess @iceburg

# modified by Chris Rainey for a Lenovo ideacentre AIO 300-22ACL
# running openbox on Ubuntu 16.04

# modified by Chris Rainey for a HP Notebook 15-ay039wm
# running openbox on Ubuntu 16.10

max=`cat ${sysfs}/max_brightness`
level=`cat ${sysfs}/brightness`

echo "Invalid usage of ${script}!"
echo "  $1"
echo "----------------"
echo "$script up     : increases brightness"
echo "$script down   : decreases brightness"
echo "$script set #  : sets brightness to # (integer)"
echo "----------------"

exit 1



if [ $level -lt 1 ] ; then
elif [ $level -gt $max ] ; then
echo $level > $sysfs/brightness 

case "$1" in
    let "level+=50"
    set_brightness $level 
    let "level-=50"
    set_brightness $level 
    if [[ ! $2 =~ ^[[:digit:]]+$ ]]; then
     usage "second argument must be an integer"

    set_brightness $2
    usage "invalid argument"

Make the file executable:

$ sudo chmod 755 /usr/local/bin/sysbacklight

Do you want to be able to run this script without entering a password or from a keyboard shortcut? Here's how:

$ sudo visudo -f /etc/sudoers.d/myOverrides

Then copy/paste the following script into your new file and customize it:

%sudo   ALL=NOPASSWD:/usr/local/bin/sysbacklight

Make the script read-only:

$ sudo chmod 440 /etc/sudoers.d/myOverrides

Now ... make a keyboard shortcut that mimics what your laptop/notebook or all-in-one keyboard might do in one of those 'other' operating systems where it normally works:

$ vi .config/openbox/rc.xml

Then copy/paste the following snippet, if using Openbox, into your ~/.config/openbox/rc.xml file between the <keyboard> ... </keyboard> sections and customize it:

    <keybind key="XF86MonBrightnessUp">
      <action name="Execute">
        <command>sudo sysbacklight up</command>
    <keybind key="XF86MonBrightnessDown">
      <action name="Execute">
        <command>sudo sysbacklight down</command>

Test, rinse & repeat as needed!

CategoryHardware CategoryCommandLine CategoryFaq CategoryVideo

ScreenBacklight (last edited 2019-05-23 19:22:26 by 76-235-14-52)