Brightness on external monitors without OSD.

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
viking777

Brightness on external monitors without OSD.

Post by viking777 »

If your Fn brightness keys work on a Linux laptop, you are a very lucky person. Normally it requires either the 'Brightness' applet to be put into your panel or xbacklight commands to be bound to keyboard shortcuts in order to be able to change brightness on a Linux machine. Even these two solutions don't work if you happen to have an external monitor attached to a laptop, it only affects the brightness on the laptop itself. You can obviously adjust this brightness with the screens OSD, but these are so annoying I hate using them. This behaviour has always bugged me and finally I have found a workround for it.

First of all you need xrandr to be installed. This is part of the package 'x11-server-utils' that is available for install through the package/software manager (if you don't already have it). If you have the package then run the command:

Code: Select all

xrandr -q | grep -w connected
I get these results:

Code: Select all

LVDS1 connected 1366x768+1280+256 (normal left inverted right x axis y axis) 344mm x 194mm
HDMI1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
So my monitors are called LDVS1 and HDMI1.

So now in order to adjust the brightness for HDMI1 (the external monitor) I need the following command:

Code: Select all

xrandr --output HDMI1  --brightness 1.0
Or

Code: Select all

xrandr --output HDMI1  --brightness 0.8
In this command 1.0 is maximum brightness and 0.8 is 80% of maximum brightness - I find this is all I need.

Of course trying to remember those commands is not all that user friendly so I suggest you create keyboard shortcuts with those commands in them.

Select 'Keyboard' from the main menu (there are two entries - choose the first). For the 'Name' use something like 'Monitor Brightness Day'. For the command use the first xrandr command above and choose a keyboard sequence that means something to you. Create another command for 'Monitor Brightness Night' and use the second xrandr command above. Obviously you can choose the percentage brightness that suits your monitor - 80% and 100% work for me.

Now all you need to do to switch between day and night brightness is to invoke one or other of the two keyboard shortcuts you just created.
lordamit

Re: Brightness on external monitors without OSD.

Post by lordamit »

hi guys,
I wrote this small program that might allow you to easily change display brightness of LVDS1 and VGA1 display devices by default, but that can easily be changed by editing the Brightness.py file.

https://github.com/lordamit/Brightness/

This simply controls brightness using xrandr in the backend, dependency is python WxWidgets for running it.
viking777

Re: Brightness on external monitors without OSD.

Post by viking777 »

lordamit wrote:hi guys,
I wrote this small program that might allow you to easily change display brightness of LVDS1 and VGA1 display devices by default, but that can easily be changed by editing the Brightness.py file.

https://github.com/lordamit/Brightness/

This simply controls brightness using xrandr in the backend, dependency is python WxWidgets for running it.
Nice one lordamit, it works for me.

For the beneift of anyone else that wants to try it, copy the code into an empty file, save it as 'brightness.py' or whatever you like, make it executable, then install python-wxgtk2.8 and its 3 dependencies from the package manager. I also had to change the external monitor name from VGA1 to HDMI1 at the beginning of the code

Code: Select all

self.externalName = "HDMI1" #change it according to xrandr output
NB if you don't know what your monitors are called run:

Code: Select all

xrandr -q | grep -w connected
Double click it and select the brightness you want. Clean, simple and nice, it has even got its own cute little panel icon. Well done :D
You could also give it a keyboard shortcut to call it from if you wanted.
lordamit

Re: Brightness on external monitors without OSD.

Post by lordamit »

Glad to know that it was of use to someone other than me :D
But reading your response, I realized that I am making the users install too many dependencies. That's not good.

I might change the UI components so that it can be executed without installing any UI related dependencies in Linux Mint :)
lordamit

Re: Brightness on external monitors without OSD.

Post by lordamit »

You guys will be pleased to hear that I have vastly modified it.
1. It now can detect the available monitors - whether it is LVDS1 or VGA213 - it will find it.
2. It can increase or decrease number of sliders based on the number of devices available.

https://github.com/lordamit/Brightness/

Please check it out, thanks! :)

[url=http://www.flickr.com/photos/lordamit/9035113863/][img]http://farm4.staticflickr.com/3760/9035113863_3f34176caa.jpg[/img][/url]
[url=http://www.flickr.com/photos/lordamit/9035113863/]Brightness Controller_018[/url] by [url=http://www.flickr.com/people/lordamit/]lordamit[/url], on Flickr
newling
Level 3
Level 3
Posts: 163
Joined: Tue Feb 04, 2020 2:26 pm

Re: Brightness on external monitors without OSD.

Post by newling »

A brilliant brightness control solution! Helped me 8 years down the line, thanks!
User avatar
Termy
Level 12
Level 12
Posts: 4254
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Brightness on external monitors without OSD.

Post by Termy »

lordamit wrote: Tue Apr 30, 2013 8:57 am ...
Nice one. I starred it. :) I usually just change the relevant value in SYSFS, but your program is much nicer, especially for those preferring GUIs.
lordamit wrote: Tue Apr 30, 2013 6:52 pm But reading your response, I realized that I am making the users install too many dependencies. That's not good.
Good of you to respond to feedback like that. I get the impression you care about your users! My kinda programmer. You could probably use SYSFS too, making it even more portable, efficient, and easier to install on various systems; it could be problematic with kernels which don't use SYSFS or use it differently, but if you're targetting Linux Mint, that likely won't be an issue any time soon, if ever.

I saw in the kernel documentation somewhere that SYSFS was never meant to be a permanent fixture, but I'm not 100% sure I'm remembering correctly.

Damn it — I didn't realise this post was so old! Awesome that it's still working well after all these years.
I'm also Terminalforlife on GitHub.
Post Reply

Return to “Tutorials”