在网上我找到了命令:
echo 1 > /sys/class/backlight/acpi_video0/brightness
为了将屏幕亮度设置为最低值,目前我正在整个磁盘中查找该路径,寻找笔记本电脑热键脚本的位置,以便我可以将步长更改为 1(因此按下我的热键只会将亮度改变 1%)。我知道有些人可能会觉得这很慢,但我对夜间屏幕亮度非常挑剔,范围的低端更加明显,因此我希望对其进行精细控制。
答案1
我找不到问题的答案(这很方便),但编写了一个带滑块的 Python GUI。我编写了两个版本,一个使用 wxPython,一个使用 Tk。
这是 tk 版本,更短一些:
import os
import subprocess
from Tkinter import *
class BrightnessSlider(object):
find_max_brightness_cmd = ['cat', '/sys/class/backlight/intel_backlight/max_brightness']
find_brightness_cmd = ['cat', '/sys/class/backlight/intel_backlight/actual_brightness']
def __init__(self, master):
min_brightness = 92
p1 = subprocess.Popen(self.find_brightness_cmd,
stdout=subprocess.PIPE)
p2 = subprocess.Popen(self.find_max_brightness_cmd,
stdout=subprocess.PIPE)
current_brightness, stderr = p1.communicate()
max_brightness, stderr = p2.communicate()
self.slider = Scale(master,
from_=int(min_brightness),
to=int(max_brightness),
orient=HORIZONTAL,
command=self.on_slide)
self.slider.set(current_brightness)
self.slider.pack()
self.slider.focus_set()
def on_slide(self, new_value):
self.set_brightness(new_value)
def set_brightness(self, new_val):
with open('/sys/class/backlight/intel_backlight/brightness', 'w') as f:
f.write(new_val)
if __name__ == "__main__":
master = Tk()
b = BrightnessSlider(master)
mainloop()