通过软件控制外部显示器亮度

你好Ubuntu社区,

我可以通过以下命令控制与DisplayPort连接的DELL U2713HM的亮度:

ddccontrol -p -r 0x10 -w 53 

在这个例子中,数字53代表亮度等级(范围0到100)。 但我不知道如何将命令链接到键盘上的亮度键。

我已经搜索过,但只是找到了集成笔记本电脑屏幕的答案。 在/sys/class/backlight是文件夹acpi_video0包含一些子文件夹和文件。 文件actual_brightness包含一个0到20之间的数字,当我按下亮度键时它会改变。

如何将我的外部显示器列为/ sys / class / backlight中的设备?

PS:我正在使用集成显卡Intel HD4000运行全新的Ubuntu 12.10安装。

我不认为你所需的外部显示器在/sys/class/backlight解决方案是可行的,但好消息是你可以拥有漂亮的亮度动画!

尝试

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

现在我们可以创建一个模拟Ubuntu亮度变换器的脚本:

 #!/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 

正如您所看到的,它会将值限制在0到100之间。现在,您可以使用系统设置>键盘>快捷方式将脚本的updown调用绑定到您选择的某些键盘快捷 ,如fotomonster建议的那样。


笔记:
我不知道ddccontrol -p需要多长时间,如果太长,你还可以在脚本中添加一个sync选项,将监视器的亮度值保存到文件中。 然后,您可以从文件中获取当前亮度,而不是从ddccontrol获取当前亮度,这应该更快。 当然,您需要更新down调用以将新亮度写入文件…


受Archlinux上这篇文章启发的脚本。