How do I programmatically change the monitor brightness on Linux?
I'm using SLES 11.
How do I programmatically change the monitor brightness on Linux?
I'm using SLES 11.
You can always use
xrandr --output LVDS1 --brightness 0.9
xrandr
and check the name of the display you have. The line will look something like "LVDS1 connected 1920x1080+0+0". –
Preestablish man xrandr
regarding --brightness
: "this is a software only modification, if your hardware has support to actually change the brightness, you will probably prefer to use xbacklight
" –
Zincography On my machine I run the following as root:
echo -n 10 > /sys/devices/virtual/backlight/acpi_video0/brightness
function brightness() {
echo $1 > /sys/class/backlight/acpi_video0/brightness
}
–
Jujube echo: write error: Invalid argument
when I tried this. You may need to check /sys/class/backlight/acpi_video0/max_brightness
first. I turned out that for me max_brightness was 7. –
Prescriptive 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.
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
You might look into using xgamma. Although it's not pure code, at least it's just a command line utility.
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
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
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
( 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
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
© 2022 - 2024 — McMap. All rights reserved.