如何通过终端命令控制背光 [英] How to control backlight by terminal command
问题描述
我试图制作一个控制Linux OS亮度的程序,但是我需要知道如何仅使用终端命令来控制显示器的背光? 我需要能够增加,减少.如果可能的话,还可以将屏幕变暗(并返回undo dim).
I am try to make a program that control the bright of Linux OS, but I need to know how to control the monitor backlight just using terminal commands? I need to be able to increase, decrease. And also dim screen (and return undo dim) if it is possible too.
推荐答案
有很多可能性.仅举几例:
There are many possibilities. Just to name a few:
1. 裸露回声
echo 8 > /sys/class/backlight/intel_backlight/brightness
查看/sys/class/backlight/intel_backlight/brightness/max_brightness以查看支持的最大亮度.
Look at /sys/class/backlight/intel_backlight/brightness/max_brightness to see what maximum brightness is supported.
2. 最简单的使用
安装xbacklight
软件包,然后尝试
xbacklight -inc 20 # increase backlight by 20%
xbacklight -dec 30 # decrease by 30%
xbacklight -set 80 # set to 80% of max value
xbacklight -get # get the current level
3.过于复杂
运行xrandr --verbose
并查找分辨率如LVDS1 connected 1024x600+0+0
的行.在此需要您的显示器名称(在此示例中为LVDS1).现在您可以设置亮度
Run xrandr --verbose
and look for a line with resolution like LVDS1 connected 1024x600+0+0
. The name of your display (LVDS1 in this example) is needed here. Now you are ready to set brightness
xrandr --output LVDS1 --brightness 0.4
但这仅设置软件,不设置硬件亮度,因此您可以超出限制(在两个方向上).不要指望美丽的结果,但是如果您足够勇敢尝试一下,那就系好安全带并跑动
But this sets only software, not hardware brightness so you can exceed the limits (in both directons). Don't expect beautiful results but if you are brave enough to experiment a little bit then fasten your seatbelt and run
xrandr --output LVDS1 --brightness 1.7
xrandr --output LVDS1 --brightness -0.4 #yes, negative value is possible
xrandr --output LVDS1 --brightness 1
您可以使用xrandr折磨更多的显示器,但是如果出现问题,请准备重新启动计算机.例如,玩以下游戏
You can torture more your display with xrandr, but be ready to reboot your computer if something goes wrong. For example play with the following
xrandr --output LVDS1 --reflect x
xrandr --output LVDS1 --reflect xy
xrandr --output LVDS1 --reflect normal # return to normal state
xrandr --output LVDS1 --rotate left
xrandr --output LVDS1 --rotate inverted
xrandr --output LVDS1 --rotate normal # again, back to normal
这篇关于如何通过终端命令控制背光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!