如何在 Linux 上更改显示器亮度?

发布于 2024-11-19 00:35:09 字数 54 浏览 8 评论 0原文

如何在 Linux 上以编程方式更改显示器亮度?

我正在使用 SLES 11。

How do I programmatically change the monitor brightness on Linux?

I'm using SLES 11.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

戒ㄋ 2024-11-26 00:35:24

仅适用于英特尔,但您可以使用xbacklight。创建/etc/X11/xorg.conf.d/20-intel.conf然后添加

Section "Device"
    Identifier  "Intel Graphics"
    Driver      "intel"
    Option      "Backlight"  "intel_backlight"
EndSection

Reboot,然后就可以使用xbacklight -set somevalue

Works only for intel, but you can use xbacklight. Create a /etc/X11/xorg.conf.d/20-intel.conf and then add

Section "Device"
    Identifier  "Intel Graphics"
    Driver      "intel"
    Option      "Backlight"  "intel_backlight"
EndSection

Reboot, and then you can use xbacklight -set somevalue

丢了幸福的猪 2024-11-26 00:35:23

编辑 /etc/default/grub 文件并

在更改后添加 “pcie_aspm=force acpi_backlight=vendor”

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

,整行将如下

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash pcie_aspm=force acpi_backlight=vendor”

Chirag Singh

edit /etc/default/grub file and add

“pcie_aspm=force acpi_backlight=vendor” after

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

after the changes, the whole line will look like this

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash pcie_aspm=force acpi_backlight=vendor”

Chirag Singh

街角迷惘 2024-11-26 00:35:23

命令:

xgamma -gamma 0.7

command for this:

xgamma -gamma 0.7

肩上的翅膀 2024-11-26 00:35:22

如果您有多个显示器并安装了 php,请将其放入

/usr/bin/brightness

#!/usr/bin/php
<?
$br=(double)$argv[1];
if(!$br||$br>1) die("enter brightness lvl 0.1 - 1");
preg_match_all('!^(\S+)!m',`xrandr --current | grep ' connected'`,$m);
foreach($m[1] as $display){
        echo `xrandr --output $display --brightness $br`."\n";
}

中,而不是调用 brightness .7

If you have multiple displays and php installed, put this in

/usr/bin/brightness

#!/usr/bin/php
<?
$br=(double)$argv[1];
if(!$br||$br>1) die("enter brightness lvl 0.1 - 1");
preg_match_all('!^(\S+)!m',`xrandr --current | grep ' connected'`,$m);
foreach($m[1] as $display){
        echo `xrandr --output $display --brightness $br`."\n";
}

than call brightness .7

梦毁影碎の 2024-11-26 00:35:22

这是在基于Linux的系统中控制亮度的简单步骤

首先,您必须知道您连接的监控屏幕。

要了解这一点,请运行此命令

xrandr -q

它将提供有关屏幕的有用信息

screen_info

(这里我的屏幕连接到了 eDP,对于您的系统可能会有所不同)

知道后运行以下命令

xrandr --output eDP --brightness [0-10]

将上面输出中的 eDP 替换为您连接的屏幕。

您可以选择 0.1 到 1.0 之间的正常亮度值

Here is the simple step to control brightness in Linux based system

First, you have to know the monitoring screen connected you.

To know this run this command

xrandr -q

It will give useful information about the screen

screen_info

( Here my screen connected to eDP, It might be different for your system )

After knowing that run the below command

xrandr --output eDP --brightness [0-10]

Replace eDP by your connected screen from the above output.

you can choose normal brightness values from 0.1 to 1.0

趁微风不噪 2024-11-26 00:35:21

ddcutil 应用程序可以通过 VESA DDC/MCCS 标准更改外部显示器的实际背光亮度(xrandr 只能在显示器当前设置的限制内移动 X11 输出,它不能改变实际的背光亮度)。这应该适用于通过显示数据通道支持该功能的任何显示器(DDC 已经存在一段时间了,它得到了广泛的支持,但仅适用于外部显示器)。我使用 ddcutil 根据从网络摄像头采样的环境光级别自动调整显示器。 Ddcutil 使用 i2c-dev 内核模块(modprobe i2c-dev 或将其设置为在启动时加载)。

ddcutil detect                    # Get list of DDC displays
ddcutil --display 2 capabilities  # List VCP feature key numbers
ddcutil --display 2 getvcp 10     # Get brightness by key number
ddcutil --display 2 setvcp 10 50  # Set brightness to 50                                                                            

The ddcutil application can change an external monitor's actual backlight brightness via the VESA DDC/MCCS standard (xrandr can only move the X11 output within a monitor's currently set limits, it can't change the actual backlight brightness). This should work for any monitors that support that capability via Display Data Channel (DDC has been around for some time, it is be widely supported, but for external monitors only). I use ddcutil to automatically adjust my monitor based on the ambient light level sampled from a webcam. Ddcutil uses the i2c-dev kernel module (modprobe i2c-dev or set it to load at boot).

ddcutil detect                    # Get list of DDC displays
ddcutil --display 2 capabilities  # List VCP feature key numbers
ddcutil --display 2 getvcp 10     # Get brightness by key number
ddcutil --display 2 setvcp 10 50  # Set brightness to 50                                                                            
断舍离 2024-11-26 00:35:21

您可能会考虑使用xgamma。虽然它不是纯代码,但至少它只是一个命令行实用程序。

You might look into using xgamma. Although it's not pure code, at least it's just a command line utility.

中二柚 2024-11-26 00:35:20

在我的机器上,我以 root 身份运行以下命令:

echo -n 10 > /sys/devices/virtual/backlight/acpi_video0/brightness

On my machine I run the following as root:

echo -n 10 > /sys/devices/virtual/backlight/acpi_video0/brightness
神仙妹妹 2024-11-26 00:35:19

对我来说,它与 xbacklight 完美配合。
例如,如果您希望设置键绑定,您可以

bindsym $SUPER+Shift+plus   exec  xbacklight -inc 10
bindsym $SUPER+Shift+minus  exec  xbacklight -dec 10

在窗口管理器配置中使用(我使用 i3)来调节屏幕的亮度级别。

我不会为此推荐 xrandr 因为它不会自动停止在 100% 亮度。

For me it works perfectly with xbacklight.
If you for example wish to set up a key binding, you can use

bindsym $SUPER+Shift+plus   exec  xbacklight -inc 10
bindsym $SUPER+Shift+minus  exec  xbacklight -dec 10

in your window managers config (I use i3) to regulate your screen's brightness level.

I wouldn't recommend xrandr for this since it doesn't stop at 100% brightness automatically.

俯瞰星空 2024-11-26 00:35:18

您可以随时使用

xrandr --output LVDS1 --brightness 0.9

You can always use

xrandr --output LVDS1 --brightness 0.9
往日情怀 2024-11-26 00:35:18

您可以尝试使用xbacklight。

xbacklight-设置 100

You can try using xbacklight.

xbacklight -set 100

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文