Monitorian icon indicating copy to clipboard operation
Monitorian copied to clipboard

Feature Request - Adaptive brightness control for external monitor

Open IUmplt opened this issue 3 years ago • 12 comments

I have seen previous request on using surface's ambient light sensor to control the brightness of the external monitor. The problem you mentioned is that the adaptive light curve would be different. I think this software Lunar (has exactly the function we would like to have for Mac) https://github.com/alin23/Lunar provides a great solution to this. You can let users to set a brightness/contrast curve on their own and use the brightness of the laptop monitor to find a point on the curve.

I think this can be a very useful feature and probably the codes for Lunar would be helpful.

IUmplt avatar Oct 21 '21 06:10 IUmplt

Thanks for the suggetion. But the adaptive light curve is supposed to be provided by each hardware vendor and I bet literally a few people can understrand the curve and set it correctly. It is not practical.

emoacht avatar Oct 25 '21 23:10 emoacht

Lunar does not use any information from the specific monitor we use. It works well with different kinds of monitors. You can see that a major part of Lunar is dedicated to implement this function and it has a good reception. I have used Lunar for a long time for my external monitor when connecting to my Macbook. Since brightness perception actually varies with people, I found it even better than the built-in adaptive brightness of Macbook sometimes.

In the implementation of Lunar, it simply use linear mapping with offsets. For a given brightness of the Macbook, it maps to a specific brightness and constrast. Users only need to set what is the monitor brightness / contrast mapped from the maximum / minimum brightness of Macbook. Their implementation is of course not perfect, but it is very useful and I think it already achieves what most people want. You can probably contact the author of Lunar to discuss on how they do this.

I think what you may misunderstand is that most users, like me, are not hoping this function to perform exactly the same as the adaptive brightness for laptops. As long as we can set the curve (or even just a linear mapping like what Lunar does) on our own, we can try to adjust the setting to find a way that works for us.

There may be technical difficulties to implement similar functions for Windows, but I think the method used by Lunar is already a practical solution and strongly suggest you to reconsider this feature. You can probably also make this a paid feature as what Lunar does and I will be more than wiling to pay for it.

Thank you very much.

IUmplt avatar Oct 25 '21 23:10 IUmplt

Thanks for the explanation. I will be happy to examine if you contribute the code for such function.

emoacht avatar Oct 26 '21 00:10 emoacht

I have checked the codes of Lunar and I think the main parts of the codes for this function is in this file https://github.com/alin23/Lunar/blob/master/Lunar/Modes/AdaptiveMode.swift.

The adaptive brightness curve is defined as below: let x be the brightness of the laptop display from 0 to 100. User can define the minimum value MinVal, the maximum value MaxVal and the offset. If the offset is 0, the monitor brightness is set to be MinVal + (MaxVal-MinVal)*x/100. When there is offset, they use a parameter called factor p so that the brightness is set to be MinVal + (MaxVal-MinVal)*(x/100)^p. The shape of the curve is controlled using the factor p. I am not sure how they relate the offset value to p, but you can simply let user to set the value of p.

The curve for contrast is defined exactly the same, with different MinVal, MaxVal and offset set by users.

I think it may be better if you can contact the author of Lunar directly to see if he is willing to help on this. I can also help the communication and check the code, though it may not be as convenient.

IUmplt avatar Oct 26 '21 01:10 IUmplt

To be clear, I have no incentive to implement it on my own.

emoacht avatar Nov 01 '21 14:11 emoacht

Ok, I think for now it may be helpful if you can leave this request open and probably write a notice on the home page to see if there is anyone who would like to help implement this feature. I think this is a feature desired by many and there may be some other people who would like to help.

I will try to work on this and contact the author of Lunar if I have time during the winter holiday. And it will be always helpful if I can have someone else to help.

IUmplt avatar Nov 01 '21 15:11 IUmplt

Just putting this here in case it can provide any help or inspiration:

I have a vaguely similar project, with what sounds like a very similar algorithm to Lunar https://github.com/jacob-pro/solar-screen-brightness it implements adaptive brightness based on sunrise and sunset times

jacob-pro avatar Nov 01 '21 16:11 jacob-pro

@IUmplt Why don't you fork and work on your own repository and ask others to help from that repository? It is the way how GitHub works.

emoacht avatar Nov 02 '21 22:11 emoacht

I do not understand. We are trying to add a feature on an existing app published on the Microsoft store. If I fork the repo and do this, how can I publish this feature to the Microsoft store? Or do you give me the permission to use your code and publish another app?

Also, it is apparent that people using this app will be viewing your GitHub page instead of mine. Do you really think it is useful that I just put a notice on my GitHub page?

I don't see a reason why you are resisting the idea of adding such a feature. It is reasonable to say that you do not want to work on it yourself, but it is not so reasonable to dismiss the idea and make harder for other people to contribute without a valid reason, especially when this feature has been requested by multiple people, and probably wished by many others.

IUmplt avatar Nov 03 '21 02:11 IUmplt

@IUmplt This obviously isn't my project, but here is some advice:

  1. This is an MIT licensed project (see the LICENSE file), which is permissive - so we are allowed to do whatever we want with the code, including putting it in another app.
  2. If you make a fork on GitHub (using the button) it will track that it is a fork so that any users viewing it can see the upstream project it originated from.
  3. Creating a fork is part of the typical GitHub workflow for contributing to a project that isn't your own - i.e. it is being suggested that you create a fork and implement the code with your desired feature. You can then create a pull request to merge code from your fork into this repo, which I'm sure the maintainers would welcome.
  4. If you would like to collaborate with others when writing this feature you can do it by accepting PRs to your fork (or granting trusted contributors access directly to your repo).
  5. This is a free and open source project maintained by volunteers, it is usually reasonable to submit a feature request, but there should be no expectation that it will be carried out, unless you go and write the code yourself and submit a PR.

jacob-pro avatar Nov 03 '21 02:11 jacob-pro

@jacob-pro Thank you very much for your comments. I understand that it is good to work on my own repo when trying to implement this code, and request to merge when I finish. I will do that when I start to work on it.

What I do not understand is that why I should ask others' help at this stage on my own repo. As you said that users can view the upstream, but few will come to my forked version from this upstream. It will be very helpful if the maintainer can put a link to my repo in this case.

I am currently unsure about the maintainer's idea on whether this feature should be incorporated to the existing app. I can try to gather help on my own, but if the eventual goal is to contribute to this project, it is kind of strange. Probably I misunderstand the maintainer's meaning and I am sorry for that if it is the case.

IUmplt avatar Nov 03 '21 03:11 IUmplt

Slightly off topic ... I have a mqtt based light sensor in my room. I've created a little program which automates the brightness setting based on the sensor value: mbri

magcode avatar Dec 05 '21 09:12 magcode

I am closing this issue.

emoacht avatar Dec 15 '22 21:12 emoacht