xanderfrangos / twinkle-tray

Easily manage the brightness of your monitors in Windows from the system tray
https://twinkletray.com
MIT License
5.45k stars 179 forks source link

[feature request] Automatically match values for all monitors #269

Open kirilloffs opened 2 years ago

kirilloffs commented 2 years ago

Hi @xanderfrangos , first let me thank you for a great app - useful and beautiful!

Many users (like myself) have a laptop connected to external display. Its common to use notebook native brightness keys to change brightness. Unfortunately such change is not applied to external monitor - only internal one. I suggest to make a feature that will equalize brightness across all displays and thus brightness keys will work universally for all monitors.

I saw in multiple topics #101 and #123 that hooking for special system keys is not available, but equalizing parameters (including brightness) is available. Similar functionality is currently implemented in ClickMonitorDDC app with "Same values for all monitors" checkbox option.

This will cover most use cases, when users want to use system default brightness keys to manage all displays at once (basically will also cover #101).

xanderfrangos commented 2 years ago

Hi @kirilloffs,

Twinkle Tray already has the ability to match brightness across all displays at once. You'll want to use two features: "Link Levels" and "Normalize Brightness".

You can adjust the brightness of all displays at once using "Link Levels": link-levels

Alternatively, you can use a hotkey that adjusts the brightness of all displays at once.

Then you can make sure all displays have the same brightness range using "Normalize Brightness": normalize-brightness

At that point, all displays will have the same brightness when using Twinkle Tray.

There is no way to hook the brightness keys on a laptop. You must use a hotkey combo. If you use a keyboard with extra function keys (ex. some Logitech keyboards), you can create a hotkey combo and have the extra function keys activate that hotkey combo.

Hope that helps!

kirilloffs commented 2 years ago

@xanderfrangos , thank you for your reply. I either haven`t explained myself clear enough or i have a bug that wont allow me to achieve desirable outcome.

I thoroughly checked for features of Twinkle Tray and have tried "Link levels" before opening an issue here. So basically I have activated "Link levels", but for me it only did the job if i change brightness levels from Twinkle Tray itself. If i use hardware keys (I am talking about system brightness key and NOT Twinkle Tray shortcut keys) would only change brightness of internal display (laptop display). External monitor brightness was not affected. Is it expected behavior?

To be clear I know that you can`t hook system keys of changing brightness. What i am suggesting is to read monitor brightness values and if they changed to change brightness of all other monitors.

What I am suggesting: Lets say laptop monitor is display 1 and external is display 2 Lets say display 1 brightness = display 2 brightness = 50% and Level Link is active. User increases brightness using native keys, which change only display 1 brightness, lets say to 60% Twinkle Tray sees that now display 1 brightness is 60% and was 50%, and increases display 2 brightness to 60% too.

This way hooking the system keys (which is not possible) is avoided and from a user standpoint it looks like default system keys now control the brightness across all monitors.

xanderfrangos commented 2 years ago

The only app I'm aware of that does this is ModernFlyouts. They hook into WMI events using C#: https://github.com/ModernFlyouts-Community/ModernFlyouts/blob/main/ModernFlyouts.Core/Utilities/BrightnessWatcher.cs

This is functionality that I can't replicate with NodeJS and don't have the knowledge to program in C++. If someone could write a NodeJS mode that does WMI event hooks (and queries), it would be super helpful for this and other Twinkle Tray features.

kirilloffs commented 2 years ago

The only app I'm aware of that does this is ModernFlyouts. They hook into WMI events using C#: https://github.com/ModernFlyouts-Community/ModernFlyouts/blob/main/ModernFlyouts.Core/Utilities/BrightnessWatcher.cs

This is functionality that I can't replicate with NodeJS and don't have the knowledge to program in C++. If someone could write a NodeJS mode that does WMI event hooks (and queries), it would be super helpful for this and other Twinkle Tray features.

@xanderfrangos I dont quite get it. You already have a variable telling you about the monitor current brightness state (monitor.brightness). Why do you need to hook to WMI events? Why can`t you just read the current brightness of the monitors with a loop and if brightness diverges just change the brightness of the second monitor?

xanderfrangos commented 2 years ago

@kirilloffs Currently, Twinkle Tray only reads the WMI brightness at startup, when opening the brightness flyout, when using hotkeys, and when Time of Day adjustments kick in.

In order for it to be responsive, Twinkle Tray would have to check for changes in the background very frequently (ex. every 0.5s). It will not feel right if you adjust the brightness and then it takes 5 seconds for the rest of your monitors to update. This means Twinkle Tray will constantly use the CPU, which will negatively affect battery life and potentially cause stutter in games. Also, people will complain about Twinkle Tray using background CPU usage (however small).

If this is ever a feature, I'd rather it be done right. Polling a value is bad practice when you can register an event.

kirilloffs commented 2 years ago

@xanderfrangos

I finally get where you are coming from. I sincerely hope that you will be able to implement native brightness keys support someday. For users like myself this is deal breaker feature and for now I have to stay on alternative software solution. However I hope i will be able to switch to twinkle tray someday. Thank you very much for thorough explanation above and for the job on the project that you do!