Bug 494956 - Automatic screen brightness change when disconnecting or re-connecting power often does not work
Summary: Automatic screen brightness change when disconnecting or re-connecting power ...
Status: RESOLVED WORKSFORME
Alias: None
Product: plasmashell
Classification: Plasma
Component: Power management & brightness (show other bugs)
Version: 6.2.4
Platform: Other Linux
: HI normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: regression
: 495126 495458 498277 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-10-17 19:59 UTC by Andrea Ippolito
Modified: 2025-03-05 08:56 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Journal log (215.55 KB, text/x-log)
2024-10-22 10:11 UTC, unsaved4197+6p4t3t5q
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Ippolito 2024-10-17 19:59:48 UTC
I think this is a regression but I don't when it happened exactly.

I have my laptop set to be at 100% screen brightness when plugged in (along with Performance mode), and at 40% screen brightness (+Balanced mode) when running on battery.

And yet when I unplug it, the power profile changes as expected, but the screen brightness stays at 100%.

My laptop is powered by an Anker USB-C dongle which also includes an HDMI port I use to extend my screen on an external monitor. Both the internal and external display are on while in use.

System settings says 6.2.1 but it's just 'cause I'm in the middle of a snapshot update, this is for 6.2.0 (haven't restarted yet to check if it's been fixed on 6.2.1)

Thanks

Operating System: openSUSE Tumbleweed 20241016
KDE Plasma Version: 6.2.1
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.3
Kernel Version: 6.11.3-1-default (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 30.7 GiB of RAM
Graphics Processor: AMD Radeon 780M
Comment 1 unsaved4197+6p4t3t5q 2024-10-22 10:11:49 UTC
Created attachment 175105 [details]
Journal log
Comment 2 unsaved4197+6p4t3t5q 2024-10-22 10:12:18 UTC
```
Operating System: CachyOS Linux 
KDE Plasma Version: 6.2.1
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.4-5-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 12 × Intel® Core™ i7-10750H CPU @ 2.60GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Manufacturer: Dell Inc.
Product Name: G3 3500
```
I'm facing the same issue on my system.
Comment 3 unsaved4197+6p4t3t5q 2024-10-22 10:16:14 UTC
And also my other system:

Operating System: CachyOS Linux 
KDE Plasma Version: 6.2.1
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.4-3-cachyos-deckify (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen Z1 Extreme
Memory: 15.3 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ROG Ally X RC72LA_RC72LA
System Version: 1.0
Comment 4 unsaved4197+6p4t3t5q 2024-10-23 18:23:19 UTC
I noticed that sometimes the brightness change works, there is no pattern however.
Comment 5 unsaved4197+6p4t3t5q 2024-10-23 18:28:15 UTC
*** Bug 495126 has been marked as a duplicate of this bug. ***
Comment 6 Michal Hlavac 2024-10-26 18:32:39 UTC
Same problem with 6.2.2 on my dell xps
Comment 7 Nate Graham 2024-11-05 21:12:35 UTC
I've been experiencing this *intermittently* on git master as well. Most of the time it doesn't work, but some of the time it does. I have not been successful in figuring out the pattern yet.
Comment 8 Nate Graham 2024-11-05 21:12:52 UTC
*** Bug 495458 has been marked as a duplicate of this bug. ***
Comment 9 MK 2024-11-29 10:50:01 UTC
This is still happening for me. 

System details:
Operating System: openSUSE Tumbleweed 20241127
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.8-1-default (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-6200U CPU @ 2.30GHz
Memory: 7.5 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 520
Comment 10 Jakob Petsovits 2024-12-18 00:05:32 UTC
Thanks for the reports, everyone.

I think the underlying cause of Bug 497362 might be somehow related to this one here as well (in a nutshell: PowerDevil's list of brightness devices isn't quite up to date at the time that the profile changes). Not entirely sure. Linking the other bug, in the hope that a fix for that one fixes or improves this one as well.
Comment 11 John Kizer 2025-01-13 19:30:43 UTC
*** Bug 498277 has been marked as a duplicate of this bug. ***
Comment 12 Jakob Petsovits 2025-01-16 16:58:40 UTC
Hi folks, I just pushed a fix for Bug 497362. Given the nature of that fix, which only concerns initial startup, I don't think that it fixes the problem described here. I'm still curious about test reports though, the fix for that bug will be in Plasma starting with 6.3 Beta 2.

I also have a second patch set in the works that should generally increase robustness of profile-based brightness settings, and would always limit them to internal displays (no special cases for "sometimes external monitors will be adjusted"). I'll CC this bug once that merge request gets uploaded, but again, hard to say if it will improve this particular case.
Comment 13 Jakob Petsovits 2025-01-16 17:16:15 UTC
(In reply to Jakob Petsovits from comment #12)
> Hi folks, I just pushed a fix for Bug 497362. Given the nature of that fix,
> which only concerns initial startup, (...)

Well... I should say "mainly concerns initial startup". It would also make a difference if the internal display is briefly disconnected for whatever reason. I'm not quite sure how KWin's list of displays responds to all kinds of events, and if it briefly marks the internal display as removed while the display configuration change is happening, the merged fix *could* conceivably fix this as well. Hence the request for more testing after Plasma 6.3 Beta 2 (or on the master branch, if you have a development build).
Comment 14 Jakob Petsovits 2025-02-21 06:36:37 UTC
Git commit 5460428e2dd1d7bac01ccbad23f501161635bd35 by Jakob Petsovits.
Committed on 20/02/2025 at 01:57.
Pushed by jpetso into branch 'master'.

actions/screenbrightnesscontrol: More robust against display changes

To avoid weird racy behavior in the case where an external monitor
may have been added prior to the internal display, we now always
limit the set of displays affected by profile state configuration
to internal displays.

This will make the "Change screen brightness" option disappear
from the Power Management KCM for systems without internal display.
No big loss for users of desktop PCs with only external monitors
and no batteries, their KCM is now tidier and Wayland users still
have brightness sliders available in the Display Configuration KCM
in addition to the Brightness and Color applet.

Also simplify conditions: the check for higher-than-min isn't needed,
so we don't have to duplicate it in the `displayAdded` handler.
`ScreenBrightnessController::setBrightness()` will already clamp
brightness to a value between min and max brightness.

Lastly, profile brightness is now also applied on `displayAdded`.
This will avoid future bugs in case we ever have more than one
internal display, one that might turn off and back on. (The case of
the first internal display appearing and disappearing is already
handled by `PowerDevil::Core` deleting the action if unsupported.)
Related: bug 498771

M  +28   -27   daemon/actions/bundled/screenbrightnesscontrol.cpp
M  +6    -3    daemon/actions/bundled/screenbrightnesscontrol.h
M  +12   -0    daemon/controllers/screenbrightnesscontroller.cpp
M  +7    -0    daemon/controllers/screenbrightnesscontroller.h

https://invent.kde.org/plasma/powerdevil/-/commit/5460428e2dd1d7bac01ccbad23f501161635bd35
Comment 15 Jakob Petsovits 2025-02-21 06:36:46 UTC
Git commit 6c875c360caadcc828c56e7a8831727d77ce75b0 by Jakob Petsovits.
Committed on 20/02/2025 at 01:57.
Pushed by jpetso into branch 'master'.

actions/screenbrightnesscontrol: Only enable for systems with battery

Users with only the AC Power profile aren't getting anything useful
from this setting in the Power Management KCM, it's rather more
confusing than it helps. This change complements the previous commit
that limited profile-based screen brightness changes to internal
displays only.

Recommended alternatives for setting screen brightness are the
Brightness and Color applet and the Display Configuration KCM,
both of which allow setting brightness separately for each display.
Related: bug 498771

M  +12   -1    daemon/actions/bundled/screenbrightnesscontrol.cpp
M  +1    -0    daemon/actions/bundled/screenbrightnesscontrol.h

https://invent.kde.org/plasma/powerdevil/-/commit/6c875c360caadcc828c56e7a8831727d77ce75b0
Comment 16 Jakob Petsovits 2025-02-21 07:12:11 UTC
Git commit 06260f7785738fe45fdcd60e1c2bbd6bd3ee2bde by Jakob Petsovits.
Committed on 21/02/2025 at 07:06.
Pushed by jpetso into branch 'Plasma/6.3'.

actions/screenbrightnesscontrol: More robust against display changes

To avoid weird racy behavior in the case where an external monitor
may have been added prior to the internal display, we now always
limit the set of displays affected by profile state configuration
to internal displays.

This will make the "Change screen brightness" option disappear
from the Power Management KCM for systems without internal display.
No big loss for users of desktop PCs with only external monitors
and no batteries, their KCM is now tidier and Wayland users still
have brightness sliders available in the Display Configuration KCM
in addition to the Brightness and Color applet.

Also simplify conditions: the check for higher-than-min isn't needed,
so we don't have to duplicate it in the `displayAdded` handler.
`ScreenBrightnessController::setBrightness()` will already clamp
brightness to a value between min and max brightness.

Lastly, profile brightness is now also applied on `displayAdded`.
This will avoid future bugs in case we ever have more than one
internal display, one that might turn off and back on. (The case of
the first internal display appearing and disappearing is already
handled by `PowerDevil::Core` deleting the action if unsupported.)
Related: bug 498771

(cherry picked from commit 5460428e2dd1d7bac01ccbad23f501161635bd35)

M  +28   -27   daemon/actions/bundled/screenbrightnesscontrol.cpp
M  +7    -3    daemon/actions/bundled/screenbrightnesscontrol.h
M  +12   -0    daemon/controllers/screenbrightnesscontroller.cpp
M  +7    -0    daemon/controllers/screenbrightnesscontroller.h

https://invent.kde.org/plasma/powerdevil/-/commit/06260f7785738fe45fdcd60e1c2bbd6bd3ee2bde
Comment 17 Jakob Petsovits 2025-02-21 07:12:19 UTC
Git commit 984548ffb494d353365c024d843126872b323dba by Jakob Petsovits.
Committed on 21/02/2025 at 07:06.
Pushed by jpetso into branch 'Plasma/6.3'.

actions/screenbrightnesscontrol: Only enable for systems with battery

Users with only the AC Power profile aren't getting anything useful
from this setting in the Power Management KCM, it's rather more
confusing than it helps. This change complements the previous commit
that limited profile-based screen brightness changes to internal
displays only.

Recommended alternatives for setting screen brightness are the
Brightness and Color applet and the Display Configuration KCM,
both of which allow setting brightness separately for each display.
Related: bug 498771
(cherry picked from commit 6c875c360caadcc828c56e7a8831727d77ce75b0)

M  +12   -1    daemon/actions/bundled/screenbrightnesscontrol.cpp
M  +1    -0    daemon/actions/bundled/screenbrightnesscontrol.h

https://invent.kde.org/plasma/powerdevil/-/commit/984548ffb494d353365c024d843126872b323dba
Comment 18 unsaved4197+6p4t3t5q 2025-03-05 08:32:46 UTC
It is working on 6.3.2.
Comment 19 John 2025-03-05 08:56:06 UTC
I noticed that by default the brighness is not going to 100% again after the cable is reconnected.
I haven't had the time to manually set everything in the system settings again.
So I'm saying that just the default as not as good as it could've been.