![Dell Inspiron 5220 屏幕亮度按钮](https://linux22.com/image/838615/Dell%20Inspiron%205220%20%E5%B1%8F%E5%B9%95%E4%BA%AE%E5%BA%A6%E6%8C%89%E9%92%AE.png)
我已经安装了 Ubuntu 13.04,除了使用按键Fn来改变笔记本电脑的亮度之外,一切似乎都很好。
它只是永远保持全亮度。
即使我进入系统设置并使用滑块更改亮度,它仍然保持最大亮度。
答案1
如果你愿意使用一些技巧,这可能会有效。
我的戴尔 Inspiron 也遇到了同样的问题,所以我想出了这个小小的 Python 脚本和一些小的改动。
我不确定它有多通用,但我的计算机在路径“/sys/class/backlight/intel_backlight”中有一个名为“brightness”的文件,此脚本依赖于该文件。如果不存在该文件,则此解决方案可能不起作用。
假设它存在,下一步就是授予我们自己写入权限。我们将此行添加到“/etc/rc.local”,以便它在启动时自动执行。我使用 nano 来编辑它。Gedit 似乎不起作用。因此在终端(Ctrl + Alt + T)中:
$ sudo nano /etc/rc.local
在之前添加此行exit 0
:
chmod 666 /sys/class/backlight/intel_backlight/brightness
如果您希望无需重启即可进行测试,您可以以 root 身份运行相同的命令:
sudo chmod 666 /sys/class/backlight/intel_backlight/brightness
现在,作为普通用户,我们可以通过该文件更改亮度。但是,我们不必每次更改亮度时都编辑该文件,而是使用一个简单的 Python 脚本:
#!/usr/bin/env python
from sys import argv
import os
PATH = "/sys/class/backlight/intel_backlight" # You shouldn't have to change this,
# if you need to and you know what
# you're doing, go ahead.
def getMax():
maxFile = open(os.path.join(PATH, "max_brightness"))
ret = int(maxFile.readline())
maxFile.close()
return ret
MAX = getMax()
MIN = 200 # You can change 200. My 0 was literally black (I could not see
# the screen), so play around with that.
INC = (MAX-MIN)/8 # You can change 8. It is approximately how many times you have
# to change the brightness before it goes from MAX to MIN, or
# vice versa.
def getCurrentBrightness():
curBrightnessFile = open(os.path.join(PATH, "brightness"))
return int(curBrightnessFile.readline())
def setBrightness(newValue):
brightnessFile = open(os.path.join(PATH, "brightness"), "w")
brightnessFile.write(str(newValue))
brightnessFile.close()
def up(increment = INC):
change(increment)
def down(decrement = INC):
change(-decrement)
def change(increment):
curBrightness = getCurrentBrightness()
newBrightness = constrain(curBrightness + increment)
setBrightness(newBrightness)
def constrain(value):
if value >= MAX: print "MAX"
if value
Now, copy that code into a file and save it wherever you like. You can end the name in ".py" as is the python tradition, but it is not required. Now make it executable. Either you can find it in Files, right click on it, click properties, click the permissions tab in the top, and make sure "Allow executing file as a program" is checked. Or you can navigate to it in the terminal and run this:
$ chmod +x /Path/to/file.py
Next, copy the path to the file, or remember it; make sure you have it. Go to "System Settings" > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" button in the bottom. For the name you can put "Brighten Screen". For command, put the path to the python script. If there are spaces in the path, surround it in quotes. After the path (outside of the quotes) put a space, and then "up".
"/path to/the/python script.py" up
Do this again, but use "Dim Screen" for the name, and use "down" instead of "up".
"/path to/the/python script.py" down
如果您单击右侧的“已禁用”标签,则可以为这些命令分配键盘快捷键。我尝试了原始的 Fn 键,但它们似乎不起作用,所以我改用 <Alt-Up> 和 <Alt-Down>。这也可以通过执行文件从终端运行,但键盘快捷键更有意义,更像原始的 Fn 键。
我在代码中添加了几条注释(行后跟“#”),其中提到了您可以更改的数字,以使其更好地为您服务,您可以查看一下。
当我在这里写出来时,这看起来非常复杂,但我可能只花了两分钟就实际添加到我的系统中(加上 python),所以我认为它应该会很顺利。
希望对您有帮助。祝您好运!