Bug 475255 - Selecting a power profile through the battery & Brightness applet doesn't work correctly; works using `powerprofilesctl`
Summary: Selecting a power profile through the battery & Brightness applet doesn't wor...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Battery Monitor (show other bugs)
Version: 5.27.10
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: 1.0
Assignee: valdikss
URL:
Keywords:
: 483454 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-10-05 20:35 UTC by dfodre
Modified: 2024-09-08 10:40 UTC (History)
11 users (show)

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


Attachments
X11 plasmashell (1.66 MB, video/mp4)
2024-01-13 20:21 UTC, valdikss
Details
Wayland (1.77 MB, video/mp4)
2024-01-13 20:50 UTC, valdikss
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dfodre 2023-10-05 20:35:01 UTC
SUMMARY
***
I have a Zenbook UM425QA (with a Ryzen 7 5800H), and selecting a power profile does absolutely nothing. The option has recently appeared in the system tray, but it's hard stuck on Balanced. The slider snaps back to Balanced if I try to drag it to Performance or Power Saver. However, the setting still applies according to `powerprofilesctl`, but you can't set it back to Balanced, because the slider says that the active profile is Balanced (even though it's not).

Going into the Power Management settings, trying to set power profiles based on charging status works, but isn't represented by the slider. It's still stuck on Balanced.
***


STEPS TO REPRODUCE
1. Go to Battery and Brightness on the system tray
2. Try to drag the slider to Power Saver (or Performance)
3. Check with `powerprofilesctl` if it works
4. Try setting the power profile to Balanced
5. Check with `powerprofilesctl` if it applies
4. Set power profiles for AC and battery power
5. Check with `powerprofilesctl` if the correct profile applies on AC and battery power respectively.

OBSERVED RESULT
The slider instantly snaps back to Balanced every time I try to move it in either direction, but the profile chosen does show as active if checked with `powerprofilesctl`. Setting it back to Balanced via the slider doesn't work. You'll be stuck either with Power Saver or Performance.
In addition, unplugging or plugging in the laptop does set it to the profile chosen in Power Management, but it isn't represented correctly in system tray. This is a way to go back to Balanced mode, but it's finicky.

EXPECTED RESULT
The slider should stay on the active setting that is reported by `powerprofilesctl`.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora Linux 38 (KDE Spin)
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.109.0
Qt Version: 5.15.10

ADDITIONAL INFORMATION
I have tried if selecting a power profile works on GNOME (by using Fedora Workstation), and it does.
Comment 1 Nate Graham 2023-10-11 20:33:24 UTC
Hmm, if `powerprofilesctl` works, than it sounds like it's not https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/106.
Comment 2 dfodre 2023-10-13 18:24:53 UTC
(In reply to Nate Graham from comment #1)
> Hmm, if `powerprofilesctl` works, than it sounds like it's not
> https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/106.

While this bug report was done on an up-to-date system when I made it, I've since updated my laptop and it seems to be fixed. The actual scrolling is a little glitchy, but it at least works now. Should this be marked as resolved?
Comment 3 Nate Graham 2023-10-13 18:29:11 UTC
Sure. If you can't reproduce it, there's no chance any of us can debug it. And if it did really just randomly start working again, then it might indeed be https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/106.
Comment 4 valdikss 2024-01-13 20:21:50 UTC
Created attachment 164877 [details]
X11 plasmashell

I have the exactly same issue:
* powerprofilesctl successfully switches between profiles
* KDE power manager is stuck on a single value (usually "balanced")
* KDE power manager successfully switches the profile when the bar is dragged, but instantly returns to the default position
* When you `kquitapp5 plasmashell && kstart5 plasmashell`, it starts to switch the profiles, but with bouncing (check the video)

Seems like there's race condition somewhere.

This is the recording on X11 Plasma session, works fine on plasmashell restart.
Comment 5 valdikss 2024-01-13 20:50:40 UTC
Created attachment 164879 [details]
Wayland

And here's on Wayland. It's "bouncy" after restarting.
Comment 6 valdikss 2024-01-13 20:52:02 UTC
Operating System: Fedora Linux 39
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.6.9-200.fc39.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × 13th Gen Intel® Core™ i5-1340P
Memory: 30,9 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: Intel(R) Client Systems
Product Name: NUC13ANKi5


plasma-desktop 5.27.10-1.fc39
Comment 7 Vladimir Yerilov 2024-03-09 16:25:24 UTC
Can confirm.
I used to have it on Intel i7 8550u laptop with Plasma 5 and hoped it would be eliminated in Plasma 6, but it's still present, and even on another machine with Ryzen 7840H. However it didn't manifest itself right after the fresh install of Manjaro which I am using on both machines, but a couple of weeks later I started to see it again.
Comment 8 Nate Graham 2024-03-13 16:07:02 UTC
*** Bug 483454 has been marked as a duplicate of this bug. ***
Comment 9 Natalie Clarius 2024-03-13 16:10:35 UTC
I've periodically had the same problem (jumps back in the applet but works via powerprofilesctl) recently in Plasma 5 too; I'll have to observe if it shows up in Plasma 6 as well.
Comment 10 Daniel Gibson 2024-03-13 16:14:52 UTC
For sake of completeness, I'll post the gist of my other report (that has been closed as a duplicated of this one):

I'm using the current development version of KUbuntu 24.04 with plasma 5.27.10-1ubuntu1 and power-profiles-daemon 0.20-3ubuntu1 on a Framework Laptop 13 with AMD Ryzen 5 7640U.

The energy profile slider always jumps back to the "Save Energy" state, no matter which mode is actually set according to `powerprofilesctl`.
Both setting another profile with the slider and with `powerprofilesctl set balanced` (or "power-saver" or "performance") works, according to `powerprofilesctl list` and `powerprofilesctl get` and `cat /sys/firmware/acpi/platform_profile`.
The slider however always jumps back to the left, and the text above it always resets to "Power Save"

This is very similar to the existing reports in this bug, except that according to powerprofilesctl switching profiles is successful, so it's most probably not a bug in power-profiles-daemon?

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 

Operating System: Kubuntu 24.04
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12
Kernel Version: 6.6.0-14-generic (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 7640U w/ Radeon 760M Graphics
Memory: 27.1 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Framework
Product Name: Laptop 13 (AMD Ryzen 7040Series)
System Version: A5
Comment 11 Daniel Gibson 2024-03-13 16:42:31 UTC
Can someone tell me where I can find the source code for this?
Searching for "battery" on https://invent.kde.org/ didn't give me any results.
Comment 12 Vladimir Yerilov 2024-03-13 17:15:50 UTC
According to my observations the slider jumps back to the previous state (not only left), which was set during the start of Plasma. No matter what that state was. Profiles switching works, it's only slider acts weird until plasmashell is restarted.
Comment 13 Jakob Petsovits 2024-03-13 17:18:53 UTC
(In reply to Daniel Gibson from comment #11)
> Can someone tell me where I can find the source code for this?
> Searching for "battery" on https://invent.kde.org/ didn't give me any
> results.

Invent's search functionality is not particularly useful in many cases. lxr.kde.org does a better job in general, in particular for cross-repository searches. You'll mainly want to look in two places:

The PowerDevil action that implements power profile switching: https://invent.kde.org/plasma/powerdevil/-/blob/v6.0.2/daemon/actions/bundled/powerprofile.cpp
Also look at:
- the associated .h file
- the corresponding .xml files for the D-Bus interfaces that it's using to communicate with power-profiles-daemon
- org.kde.Solid.PowerManagement.Actions.PowerProfile.xml which uses the PowerProfile class to expose its own D-Bus service

The Power and Battery applet: https://invent.kde.org/plasma/plasma-workspace/-/blob/v6.0.2/applets/batterymonitor/package/contents/ui/main.qml
Also look at:
- PopupDialog.qml and PowerProfileItem.qml in the same directory, which are child items of main.qml
- The associated dataengine that exposes PowerDevil's D-Bus service to the applet: https://invent.kde.org/plasma/plasma-workspace/-/blob/v6.0.2/dataengines/powermanagement/powermanagementengine.cpp
Comment 14 Daniel Gibson 2024-03-13 17:48:06 UTC
Thank you, I might take a look at the source if I find some more time :)
Comment 15 Daniel Gibson 2024-03-13 18:24:21 UTC
I haven't looked at the code, but quickly tried the following (I'll add comments starting with "#" between the lines to document what I did):

$ dbus-monitor "interface='org.kde.Solid.PowerManagement.Actions.PowerProfile'"
signal time=1710353718.842724 sender=org.freedesktop.DBus -> destination=:1.164 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.164"
signal time=1710353718.842774 sender=org.freedesktop.DBus -> destination=:1.164 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.164"

# set profile to balanced with the slider (which immediately jumped back) 

method call time=1710353728.906855 sender=:1.41 -> destination=org.kde.Solid.PowerManagement serial=3938 path=/org/kde/Solid/PowerManagement/Actions/PowerProfile; interface=org.kde.Solid.PowerManagement.Actions.PowerProfile; member=setProfile
   string "balanced"
signal time=1710353728.972333 sender=:1.46 -> destination=(null destination) serial=2018 path=/org/kde/Solid/PowerManagement/Actions/PowerProfile; interface=org.kde.Solid.PowerManagement.Actions.PowerProfile; member=currentProfileChanged
   string "balanced"

# run `$ powerprofilesctl set power-saver`

signal time=1710353735.988951 sender=:1.46 -> destination=(null destination) serial=2020 path=/org/kde/Solid/PowerManagement/Actions/PowerProfile; interface=org.kde.Solid.PowerManagement.Actions.PowerProfile; member=currentProfileChanged
   string "power-saver"

# moving slider to performance (it immediately jumped back)

method call time=1710353743.614882 sender=:1.41 -> destination=org.kde.Solid.PowerManagement serial=3939 path=/org/kde/Solid/PowerManagement/Actions/PowerProfile; interface=org.kde.Solid.PowerManagement.Actions.PowerProfile; member=setProfile
   string "performance"
signal time=1710353743.654630 sender=:1.46 -> destination=(null destination) serial=2021 path=/org/kde/Solid/PowerManagement/Actions/PowerProfile; interface=org.kde.Solid.PowerManagement.Actions.PowerProfile; member=currentProfileChanged
   string "performance"


This makes me wonder if this is the same bug as "my" other bug: https://bugs.kde.org/show_bug.cgi?id=471010
In both cases PowerDevil sends the correct DBus messages, but the UI sticks (or in this case reverts) to some nonsense-value, maybe one it set on boot or something.

TBH I have zero experience with Qt development, so it would be nice if someone else could debug what's exactly going wrong in the battery monitor - or if you can't reproduce it, instruct me what to do :)
Comment 16 Diyou 2024-04-23 05:40:01 UTC
I'm experiencing the same with plasma 6.0.4 on arch.
Killing and restarting the plasmashell fixes the slider and a possibly related bug where video playback and games would not inhibit sleep/screensaving.
Comment 17 Andres Rivas 2024-04-26 15:17:09 UTC
To add to this bug, I'm experiencing it on kubuntu 23.10, either installed and live cd, but not on kubuntu 22.04 nor 24.04 live cds:

=========== BUG PRESENT ===========
Operating System: Kubuntu 23.10
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.5.0-28-generic (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 7.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20X4S27300
System Version: ThinkPad L15 Gen 2
===================================

======== BUG NOT PRESENT 1 ========
Operating System: Kubuntu 22.04
KDE Plasma Version: 5.24.7
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3
Kernel Version: 6.5.0-18-generic (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 7.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
===================================


======== BUG NOT PRESENT 2 ========
Operating System: Kubuntu 24.04
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13
Kernel Version: 6.8.0-31-generic (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 7.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20X4S27300
System Version: ThinkPad L15 Gen 2
===================================


Diyou's workaround of restarting plasma seems to work, but its kind of inconvenient
Comment 18 Nate Graham 2024-04-26 16:52:59 UTC
Apparently there was an issue on our side, as it went away completely for me with a recent change to the widget for Plasma 6.1.
Comment 19 valdikss 2024-09-06 17:02:01 UTC
(In reply to Nate Graham from comment #18)
> Apparently there was an issue on our side, as it went away completely for me
> with a recent change to the widget for Plasma 6.1.

Will it be updated for KDE 5 version?
Comment 20 valdikss 2024-09-06 17:02:36 UTC
(In reply to valdikss from comment #19)
> (In reply to Nate Graham from comment #18)
> > Apparently there was an issue on our side, as it went away completely for me
> > with a recent change to the widget for Plasma 6.1.
> 
> Will it be updated for KDE 5 version?

I'm still on Fedora 39, the issue is present on

Operating System: Fedora Linux 39
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.116.0
Qt Version: 5.15.14
Kernel Version: 6.10.7-100.fc39.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 21 Nate Graham 2024-09-08 10:40:56 UTC
We generally aren't backporting anything to 5.27 anymore, sorry. There are exceptions for narrowly-targeted fixes and well-understood code. In this case that's not possible since the widget has been received a huger number of large changes between 5.27 and 6.1.