Ubuntu – Control monitor brightness with keyboard shortcut


I can control the brightness of my DELL S2216H connected with HDMI via the command:

ddccontrol -p -r 0x10 -w 53

where in this example the number 53 represents the brightness level (range 0 to 100). But I don't know how to link the command to my brightness keys on my keyboard or add laptop like slider next to volume control in Gnome-panel

while searching on the topic, i read this question
Control external monitor brightness via software
but the accepted answer to that question doesn't solve my issue

my output of ddccontrol -p is is posted here at pastebin

tried the first solution.

python3 /home/sumeet/set_brightness.py up

No monitor supporting DDC/CI available.
If your graphics card need it, please check all the required kernel modules are loaded (i2c-dev, and your framebuffer driver).
Traceback (most recent call last):
  File "/home/sumeet/set_brightness.py", line 22, in <module>
    currval = int(next(obj for obj in section if obj.startswith("value")).split("=")[-1].strip(","))


output of This Script from what I understand it's not even detecting my monitor. but first (original) command still works

python3 /home/sumeet/brightness.py
No monitor supporting DDC/CI available.
If your graphics card need it, please check all the required kernel modules are loaded (i2c-dev, and your framebuffer driver).
ddccontrol version 0.4.2
Copyright 2004-2005 Oleg I. Vdovikin (oleg@cs.msu.su)
Copyright 2004-2006 Nicolas Boichat (nicolas@boichat.ch)
This program comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of this program under the terms of the GNU General Public License.

Probing for available monitors.......
Detected monitors :

even the first command isn't working now, how can i get that working?

Brightness Slider in laptops

Best Answer

Bind a keyboard shortcut

Gnome allows you to bind any key to run a command of your choice. If xbacklight worked, I'd suggest you use that. Since you said it does not, you can use the brightness script I'll include below.

  1. Go to Settings → Keyboard → Shortcuts and scroll to the bottom of the list.
  2. You'll find a + button. Click it to open the Add Custom Shortcut dialog: Add Custom Shortcut
    1. For the Name put "Brightness Up", for the Command, type brightness +10
    2. Click the "Set Shortcut" button and hit the key you want to turn the screen brighter.
  3. Now do the same for "Brightness Down", using brightness -10. Add shortcut

b9's brightness script

Many external monitors cannot control the backlight lamp with xbacklight. But you can still control the brightness using software. Here's a script I wrote which does that.

# brightness: Change all monitors brightness in software.
# by hackerb9, 2019

# Examples:  brightness 75;  brightness -5; brightness +10
# Usage:
#       brightess [n] [+n] [-n]
#       n       An integer from 0 to 100 specifies a brightness level.
#       +n      Increase brightness by n.
#       -n      Decrease brightness by n.
#               No argument shows current brightness level.

b=$(xrandr --current --verbose | grep Brightness)
b=${b#*: }                      # Remove "Brightness: "
b=${b#0.}                       # 0.30 --> 30
[[ $b == "1.0" ]] && b="100"
case $1 in
        b=$((b $1))             # b=b+10,  b=b-10
        b=$1                    # b=75
        echo $b; exit

[[ $b -lt 0 ]] && b=0
[[ $b -gt 100 ]] && b=100

if [[ $b -eq 100 ]]; then

outputs=$(xrandr --current | awk '$2 == "connected" {print $1}')
for o in $outputs; do
    xrandr --output $o --brightness $b

To install the script, paste it into a file called brightness, set it executable, and put it in your path. Or, you can cut-and-paste these commands:

  1. wget https://github.com/hackerb9/brightness/raw/master/brightness
  2. chmod 755 brightness
  3. sudo mv brightness /usr/local/bin/


If xbacklight did work for you, you could use it as a drop-in replacement for brightness in the above instructions. (xbacklight +10 for Brightness Up, xbacklight -10 for Down.)