Is it possible to adjust desktop monitor brightness like on laptops?
Yes all desktop monitors have separate menu for it.
But is it possible to change this to something like Winkey+(F1..F12)?

Monitor is connected via VGA or DVI cable.

  • OS: Ubuntu 14.04
  • Desktop monitors

With the script below, you can set the screen's brightness from 0.1 to 1.0, in 9 steps, on any system that "obeys" xrandr.

Just run it with either the argument "up" or "down" to increase/decrease the current brightness one step.

The script

#!/usr/bin/env python3
import subprocess
import sys

arg = sys.argv[1]

# get the data on screens and current brightness, parsed from xrandr --verbose
current = [l.split() for l in subprocess.check_output(["xrandr", "--verbose"]).decode("utf-8").splitlines()]
# find the name(s) of the screen(s)
screens = [l[l.index("connected")-1] for l in current if "connected" in l]
# find the current brightness
currset = (round(float([l for l in current if "Brightness:" in l][0][1])*10))/10
# create a range of brightness settings (0.1 to 1.0)
sets = [n/10 for n in list(range(11))][1:]
# get the current brightness -step 
step = len([n for n in sets if currset >= n])

if arg == "up":
    if currset < 1.0:
        # calculte the first value higher than the current brightness (rounded on 0.1)
        nextbright = (step+1)/10
if arg == "down":
    if currset > 0.1:
        # calculte the first value lower than the current brightness (rounded on 0.1)
        nextbright = (step-1)/10
    for scr in screens:
        # set the new brightness
        subprocess.Popen(["xrandr", "--output", scr, "--brightness", str(nextbright)])
except NameError:

How to use

  1. Copy the script into an empty file, save it as set_brightness.py
  2. Test- run it by the commands:

    python3 /path/to/set_brightness.py up


    python3 /path/to/set_brightness.py down
  3. If all works fine, add both commands to shortcut keys: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add both commands above to two different shortcut keys.


The explanation on the code is pretty much in the script :)


As it is, the scripts sets the brightness equally for both the "main" and possible additional screen(s).

  • Hi. Sorry. I have forgot to answer. It works, but a bit different as on laptops. – UNIm95 Oct 11 '15 at 12:34
  • slow. for faster, see askubuntu.com/questions/1150339/… – Joe Dec 24 '19 at 10:25
  • Hey Joe, couldn't test the linked script, getting xrandr: Need crtc to set gamma on. However on the script above: real 0m0,048s which seems more than sufficient for the task. Speed is not a subject issue here. – Jacob Vlijm Dec 24 '19 at 10:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.