如何在 VAIO 中使用 xbacklight 和亮度键

如何在 VAIO 中使用 xbacklight 和亮度键

我有一台 Sony VAIO VPCCW15FL,安装了 Ubuntu 12.04。

遗憾的是,亮度键开箱后无法使用,尽管亮度计对亮度升高/降低按键有反应。

昨天,我安装了 xbacklight 并从终端尝试了它。作为普通用户(没有 sudo),我可以运行 xbacklight -40,例如,背光变暗。效果很好。

然后我打开键盘设置,尝试设置两个自定义快捷键来控制背光亮度。我将其中一个命名为“亮度调高”,xbacklight +10命令为。然后我单击设置键,出现“显示器亮度调高”(作为键),因此检测到了它。但是,即使重新启动后,它也没有用。我尝试将命令更改为,/usr/bin/xbacklight +10但它也不起作用。

这有什么问题?另外,我想知道我是否可以让亮度计使用 xbacklight 命令而不是其默认命令。是否有任何文件可以更改以执行此操作?我认为这比定义快捷方式更好,因为它会与亮度栏集成。谢谢 :)

答案1

好的,我找到了一个不同的解决方案,它也适用于其他笔记本电脑,而不仅适用于 VAIO。

确保 xbacklight 和 inotify-tools 已安装,我刚刚运行了sudo apt-get install xbacklight inotify-tools

配置以下脚本并将其保存为bash脚本(例如,保存为backlight_control.sh),并使用赋予其可执行权限chmod +x backlight_control.sh

然后将其添加到启动应用程序中(在 12.04 中可以通过单击屏幕右上角的菜单项来完成)。背光级别应恢复到以前的设置,并且控件应开始工作,登录会话后. 亮度计也显示正确的值。

我希望这能帮助到遇到同样问题的人。欢迎对其性能或其他方面提出任何评论。

#!/bin/bash

# Script for setting the correct brightness for the backlight.
# Depends on: xbacklight and inotify-tools,
# Which can be installed by running:
#       `sudo apt-get install xbacklight inotify-tools`
#
# Author: Esteban Serrano Roloff <e.serrano.r (at) me.com>
#
# Tested on a Sony VAIO VPCCW15FL
# running Ubuntu 12.04
# 2013-03-27 (YYYY-MM-DD)

# Setup the correct paths (look inside /sys/class/backlight/)
current_brightness_path="/sys/class/backlight/sony/brightness"
max_brightness_path="/sys/class/backlight/sony/max_brightness"
# To find the correct value for min_brightness, make the
# brightness meter go to its minimum (by repeatedly pressing
# the brightness down key), even if the actual brightness stays
# the same, and then run on a terminal:
#       `cat /sys/class/backlight/sony/brightness`
min_brightness=0


#### No editing needed beyond this line (I hope) ####
max_brightness=`cat $max_brightness_path`
range=${max_brightness-min_brightness}



# Set the correct brightness level on start up.
current_brightness=`cat $current_brightness_path`
let current_brightness_pctg=100*$current_brightness/$range
xbacklight =$current_brightness_pctg

# Listen for brightness changes, forever.
while inotifywait -e close_write $current_brightness_path; do

    current_brightness=`cat $current_brightness_path`
    let current_brightness_pctg=100*$current_brightness/$range
    xbacklight =$current_brightness_pctg

done

相关内容