11

Hello Ubuntu community,

I can control the brightness of my DELL U2713HM connected with DisplayPort 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.

I searched already, but just found answers to integrated laptop screens. In /sys/class/backlight is the folder acpi_video0 with some subfolders and files. The file actual_brightness contains a number from 0 to 20, which is changing when I press the brightness keys.

How do I get my external monitor listed as a device in /sys/class/backlight ?

PS: I am running a fresh Ubuntu 12.10 install with integrated graphics Intel HD4000.

4
  • When the command you provided works for your external monitor you can set custom shortcut keys in System Settings > Keyboard > Shortcuts.
    – tongpu
    Nov 27, 2012 at 22:18
  • That is correct, but then I can just send two commands (dark/bright) and I would ignore the Ubuntu internal brightness changer with the nice brightness animation.
    – remi
    Nov 29, 2012 at 7:21
  • Can you post a link with the output of ddccontrol -p, I'm thinking of a solution... Jan 9, 2013 at 18:55
  • Hope this is any help for you: pastebin.com/L7Y7pRZe
    – remi
    Jan 10, 2013 at 7:12

1 Answer 1

6
+50

I don't think your desired solution of getting your external monitor in /sys/class/backlight will work, but the good news is that you can have the nice brightness animation!

Try

notify-send " " -i notification-display-brightness-low -h int:value:50 -h string:x-canonical-private-synchronous:brightness &

Now we can make a script that simulates Ubuntu's brightness changer:

#!/bin/bash
#get current brightness
presbright=$(ddccontrol -p | grep -A1 0x10 | tr -d '\n\t' | sed 's/.*value=\([^a-zA-Z]*\),.*/\1/')
#stepsize for the brightness change
stepsize=10

case "$1" in
        up)
          newbright=$(( ${presbright}+${stepsize} ))
          newbright=$(echo $newbright | awk '{if($1 < 100){if($1 > 0) print $1; else print 0;} else print 100;}')

          notify-send " " -i notification-display-brightness-low -h int:value:$newbright -h string:x-canonical-private-synchronous:brightness &
          ddccontrol -p -r 0x10 -w $newbright
        ;;
        down)
          newbright=$(( ${presbright}-${stepsize} ))
          newbright=$(echo $newbright | awk '{if($1 < 100){if($1 > 0) print $1; else print 0;} else print 100;}')

          notify-send " " -i notification-display-brightness-low -h int:value:$newbright -h string:x-canonical-private-synchronous:brightness &
          ddccontrol -p -r 0x10 -w $newbright            
        ;;
        status)
          echo $presbright
        ;;
        *)
          echo "Accepted arguments are: up, down, status."
        ;;
esac

exit 0

As you can see it clamps the values between 0 and 100. Now you can bind the up and down calls to the script to some keyboard shortcuts of your choice with System Settings > Keyboard > Shortcuts, like fotomonster suggested.


Notes:
I don't know how much time ddccontrol -p takes, if it is too long you can also add a sync option to the script which saves the brightness value of the monitor to a file. Then instead of getting the current brightness from ddccontrol you can simply get it from your file, which should be much faster. Of course you would need to update the up and down calls to write the new brightness to the file...


script inspired by this post on archlinux.

2
  • works very well, thank you very much. That is exactly what I wanted. Now the whole system is well integrated, like an iMac, but still configurable.
    – remi
    Jan 10, 2013 at 12:18
  • Still need a little help, binding the script to my brightness keys: askubuntu.com/questions/239560/…
    – remi
    Jan 10, 2013 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .