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.
ddccontrol -p
, I'm thinking of a solution...