Home Command line utilities How To Adjust Monitor Brightness From Command Line In Linux
Adjust Monitor Brightness in Linux

How To Adjust Monitor Brightness From Command Line In Linux

By sk
3668 Views

This brief tutorial explains how we can adjust monitor brightness from command line in Unix-like operating systems. Adjusting screen brightness in GUI mode is easy. We already have reviewed a Brightness Controller GUI app which will help us to control the brightness in Ubuntu-like operating systems. But, this app development seems to be stalled for more than a year and I am not sure whether it will work with recent Ubuntu versions. Another disadvantage is the Brightness Controller app is compatible with Python2 only. While looking for an alternative ways, I learned that we can easily do this with a command line utility named "xrandr".

The xrandr program is used to set the size, orientation and/or reflection of the outputs for a screen. Using Xrandr, we can also display the current state of the system screen, change or set the resolution, disable disconnected outputs and enable connected ones. And the good thing is Xrandr comes pre-installed with most Linux distributions, so we don't have to bother with installing additional tools/apps.

Adjust Monitor Brightness From Command Line In Linux

First, we need to check the current state of system display. To do so, run:

$ xrandr -q

Sample output:

Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
LVDS-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1366x768 60.00*+ 40.00 
1280x720 60.00 59.99 59.86 59.74 
1024x768 60.04 60.00 
960x720 60.00 
928x696 60.05 
896x672 60.01 
1024x576 59.95 59.96 59.90 59.82 
960x600 59.93 60.00 
960x540 59.96 59.99 59.63 59.82 
800x600 60.00 60.32 56.25 
840x525 60.01 59.88 
864x486 59.92 59.57 
700x525 59.98 
800x450 59.95 59.82 
640x512 60.02 
700x450 59.96 59.88 
640x480 60.00 59.94 
720x405 59.51 58.99 
684x384 59.88 59.85 
640x400 59.88 59.98 
640x360 59.86 59.83 59.84 59.32 
512x384 60.00 
512x288 60.00 59.92 
480x270 59.63 59.82 
400x300 60.32 56.34 
432x243 59.92 59.57 
320x240 60.05 
360x202 59.51 59.13 
320x180 59.84 59.32 
VGA-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)

As you can see, the currently connected display is LVDS-1. This output displays current resolution and screen refresh rate.

If you want to know the only the active display name, use "grep" and "head" commands with "xrandr" as shown below.

$ xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1
LVDS-1

The brightness value must be between 0.0 to 1.0 where 0.0 refers the dimmest (full black) and 1.0 refers the brightest value. For example, to set screen brightness value as 0.7, run:

$ xrandr --output LVDS-1 --brightness 0.7

Replace LVDS-1 with your active display name. Here, 0.7 refers the 70% of the maximum display brightness.

To go back to normal brightness, run:

$ xrandr --output LVDS-1 --brightness 1.0

Don't use anything above 1.0. It might turn the display into full white and you may not clearly see anything in the screen.


Suggested read:


Hope this was useful.

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

14 comments

01101001b May 30, 2019 - 6:22 am

This is EXACTLY what I was searching for. Thank you so much!

Reply
kumar September 10, 2019 - 1:28 am

It works. Thank you.

Reply
Sturge October 3, 2019 - 7:06 am

There’s a simpler way: xgamma -gamma 1.0
1.0 is the default value. Use 2.0 to double the brightness, 0.5 to halve it, etc.

Reply
sk October 3, 2019 - 10:31 am

I didn’t know it. Thank you.

Reply
Agathe October 3, 2019 - 5:12 pm

try xbacklight

Reply
Stef October 3, 2019 - 7:04 pm

As far as I know, gamma and brightness are two different things. See here for a detailed comparison https://graphicdesign.stackexchange.com/questions/11445/gamma-vs-brightness-any-difference. Conceptually, the gamma is more like the ‘contrast’ than that ‘brigthness’. That does not mean that xgamma is useless but using it to control the brightness of the screen is probably a bad idea.

Reply
Stef October 3, 2019 - 7:22 pm

The problem with xrand is that it probably does not work when using a Wayland based desktop. This is because xrandr relies on X11 protocols that are only supported read-only in XWayland (the X11 emulation layer of Wayland). That makes sense since XWayland is not in charge of the whole screen when using a Wayland desktop.
For my Sway desktop, I am currently using https://github.com/Hummer12007/brightnessctl with the commands
brightnessctl 10%+ # increase brightness by 10%
brightnessctl 10%- # decrease brightness by 10%
That tool is not specific to Wayland. It talks directly to the backlight device exposed by the Linux kernel in /sys/class/backlight

Reply
sk October 4, 2019 - 10:53 am

Thanks for the update. I never knew it. I will give it a try soon.

Reply
Stef October 4, 2019 - 4:57 pm

Another thing that people should be aware of is that the expected behavior is that the minimum brightness value should not very dark but still visible. Unfortunately, for some graphic cards (e.g. Intel) the minimum value of 0 produces a completely black screen which can be quite annoying. I could not find a proper solution to that problem so a few months ago, I wrote a small daemon script that monitors the value reported by the backlight device are reset it to 1 when it falls to 0 (must be run a root)

======
#!/bin/bash
B=/sys/class/backlight/intel_backlight/brightness
if [ -f $B ] ; then
inotifywait -q -e close_write -m $B | while read -r filename event; do
V=$(cat $B)
if [ “$V” -eq 0 ] ; then
echo 1 > $B
fi
done
fi
=============

You may have to change /sys/class/backlight/intel_backlight/brightness to whatever blacklight device you are currently using.

And of course, the script must be started at boot. For systemd user, see the example in https://www.linode.com/docs/quick-answers/linux/start-service-at-boot/

Reply
Marllon October 6, 2019 - 12:05 pm

Thank you so much!

Reply
Jani "robsku" Saksa November 13, 2019 - 8:51 am

I don’t know why, but with Vivaldi browser, the comments are the same color as the background… All I saw was avatars and nicks, until I turned the reader-mode on, but then I couldn’t post a reply (this for is also very hard to see, white (or very-light-gray) or bright white?

Anyway, I tried your xrandr command, and although it seems that 1.0 was the set brightness, I tried 1.2 and it worked… so I tried more, 1.3 and 1.5 – then finally 2.0, and they work – 1.0 looks dark to me now, but I know it will consume more battery, and if I just turn it back down I know I’ll get used to it in couple minutes…

Strange… Could it be a video driver thing? You did say that the 1.0 should be the brightest possible, right?

I’m very curious – btw, is there a panel app for screen brightness for xfce? Oh, lazy me… no, tired.

Reply
sk November 13, 2019 - 12:24 pm

I clearly mentioned -“Don’t use anything above 1.0.” Why did you use it beyond 1.0? I haven’t tried beyond 1.0. So I can’t comment about it. And yes, it might be Video driver thing. There is a GUI app called “Brightness Controller” to control the brightness of the display. It works on GNOME DE. Not sure if it works under XFCE. Give it a try and see if it works. Good luck. https://ostechnix.com/brightness-controller-simple-gui-application-control-brightness-ubuntu/

Reply
Bas July 2, 2020 - 3:11 pm

Thank You as well. This is EXACTLY what I was searching for. I Could not find via the Peppermint Setting Panel any brightness adjustment , where is it ???….
With your instruction, first it didn’t work out. I followed exactly “copy and paste” of the given commands, but it did not recognised “LVDS-1”. I read the result of the first command typed into my terminal and realise that it has LVDS1 instead of LVDS-1. So I repeated the instruction with LVDS1 and increased the brightness to initially to 0.7 but it made even more darker, so I have changed to 1.1 (the letters appeared to become thinner) the white background is still creamy but the 1.3 made the letters even more thinner. I will stay with it for a while and see. Thanks a lot. Light and Peace

Reply
sk July 2, 2020 - 3:39 pm

Glad you solved it yourself. Most of the issues will be fixed easily if we carefully read the output. Have a good day!

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More