Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
When the command you provided works for your external monitor you can set custom shortcut keys in System Settings > Keyboard > Shortcuts. –  fotomonster Nov 27 '12 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 '12 at 7:21
    
Can you post a link with the output of ddccontrol -p, I'm thinking of a solution... –  Gerhard Burger Jan 9 '13 at 18:55
    
Hope this is any help for you: pastebin.com/L7Y7pRZe –  remi Jan 10 '13 at 7:12
add comment

1 Answer 1

up vote 3 down vote accepted
+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.

share|improve this answer
    
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 '13 at 12:18
    
Thanks! You're welcome. –  Gerhard Burger Jan 10 '13 at 12:19
    
Still need a little help, binding the script to my brightness keys: askubuntu.com/questions/239560/… –  remi Jan 10 '13 at 14:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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