How to change the Monitor brightness on Linux?
Asked Answered
Q

11

22

How do I programmatically change the monitor brightness on Linux?

I'm using SLES 11.

Quesnay answered 8/7, 2011 at 14:22 Comment(1)
possible duplicate of Possible to change screen brightness with c?Quesnay
E
31

You can always use

xrandr --output LVDS1 --brightness 0.9
Eosinophil answered 21/12, 2012 at 18:37 Comment(5)
"LVDS1" is the name of the display you want to change. Run xrandr and check the name of the display you have. The line will look something like "LVDS1 connected 1920x1080+0+0".Preestablish
Quote from 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
change LVDS1 to eDP if you have a laptop, if you have a DP monitor and have it connected with DP, use DP instad, same with DVI1,DVI2 etcWatercolor
Amr is right. This can turn all white to black, or all black to white; but not make the white brigherHammy
As this answer do not really changes the brightness of the monitor you better try the possibilities from this answer: askubuntu.com/a/1181157/1046889Whirligig
H
14

You can try using xbacklight.

xbacklight -set 100

Herr answered 26/3, 2013 at 17:44 Comment(0)
D
4

On my machine I run the following as root:

echo -n 10 > /sys/devices/virtual/backlight/acpi_video0/brightness
Downrange answered 8/7, 2011 at 14:47 Comment(3)
This is what I use, but typing this command each time is a pain, so you might want to add a shell function to your .bashrc file, something like function brightness() { echo $1 > /sys/class/backlight/acpi_video0/brightness }Jujube
I got 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
It works, but brightness 0 only results in a darker screen, not in blank dark screen (like turn off) !!! Any idea why ?Hypogastrium
T
4

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.

Tactical answered 8/10, 2015 at 22:57 Comment(0)
K
2

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                                                                            
Kelleekelleher answered 19/7, 2021 at 3:41 Comment(1)
Subsequent to answering this question, I have written my own desktop tray GUI front end to ddcutil specifically for quick access to backlight adjustments. If you need such a tool, see vdu_controls at github.com/digitaltrails/vdu_controls or the brief write up at forums.opensuse.org/showthread.php/…Kelleekelleher
A
0

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

Adaminah answered 8/7, 2011 at 14:48 Comment(1)
xgamma is not a monitor brightness, it is image filtering before output it into VGA card.Flock
O
0

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

Oscar answered 13/2, 2015 at 20:0 Comment(0)
P
0

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

Punkah answered 23/6, 2017 at 10:46 Comment(0)
P
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

Potts answered 30/8, 2020 at 4:46 Comment(0)
D
0

command for this:

xgamma -gamma 0.7

Denotation answered 1/12, 2020 at 9:37 Comment(0)
M
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

Mcmullan answered 24/7, 2023 at 7:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.