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...
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
: 483454 (view as bug list)
Depends on:
Reported: 2023-10-05 20:35 UTC by dfodre
Modified: 2024-03-15 22:37 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:

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

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
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.

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.

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.

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

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

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]

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?

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 :)