Power Management in 5.3

Hello Planet!

A few weeks ago Alex Fiestas passed maintainership of PowerDevil, KDE’s power management service, over to me (thanks!), and there have been many exciting things going on in the power management department. Let’s take a look!

The past week has been an exciting one, with Plasma 5.2’s release to the public – it will be the first incarnation of the new Plasma architecture getting widely adopted by distributions. As far as PowerDevil is concerned, we made the screenlocker more reliable, and added transitions before suspending or turning off the screen to minimize the chance of a long wakeup process. Other than that it has been mostly dead code removal.

What’s ahead?

First of all, the Plasma 5.2.1 release contains a fix for an unfortunate bug that caused kded to eat 100% CPU on certain setups. Another interesting one I fixed was Chrome not keeping your screen on while watching a video – it’s easy just to blame Chrome for everything but it turned out that it posted an inhibition but PowerDevil didn’t properly handle it. Also restored is the missing config option for what pressing the power button should do.

Shiny new features

Enough text already, let’s look at some pictures!

Google Chrome suppressing power management
Google Chrome suppressing power management
Not suspend when closing the lid with an external monitor
Not suspending when closing the lid with an external monitor

As you can see, battery monitor can now display which application(s) is/are currently holding a power management inhibition and why (the spec requires an application to state a reason and thankfully most applications actually do). So, if you ever wonder why or why not your screen turns off, first check it out here :)

Another seemingly magic feature in the 4.x times has been KScreen preventing the device from suspending when you closed the lid while an external monitor was connected since you’re likely to watch a movie or do a presentation with it. This returns to Plasma 5.3 but now it will show a hint when it will do so, and of course this behavior can be disabled (on a per-Activity basis, even!) for instance when you’re using a docking station in the office.

Re-entering the stage are activity-related power management settings allowing you to override power management settings on a per-activity basis.

Other changes and improvements

– Automatic screen locking will be prevented by a power management inhibition
– Improved cumulative battery handling; your lock screen will now show the proper percentage, not a random battery that happens to be #1 (could be your mouse, for instance)
– Grace period before suspending or turning off the screen, it will fade the screen to black 5 seconds prior so you could cancel the imminent action
– Various ports to XCB and async calls

Powerdevil warning about a low mouse battery
Powerdevil warning about a low mouse battery

How to get involved?

Of course there are many more things to come that may or may not make it into the 5.3 release, such as warning about low mouse and keyboard batteries, and animated/smooth brightness change.

There is a Power Management todo list (needs KDE identity login) with tasks you can have a look at, there’s even some junior jobs! Bug reports go to KDE Bugzilla product PowerDevil and if you have any questions, suggestions, or preferably patches ;) feel free to ping kbroulik in #plasma or #solid on freenode.


22 thoughts on “Power Management in 5.3”

  1. “Also restored is the missing config option for what pressing the power button should do.”

    Well, thanks for forcing me to use a unstable build again ;) This feature I was missing most of all since I switched to the 5.x series. CTRL-F1 did the job a little bit for watching movies, but the backlight kept using power. The same for long compilation jobs in the night.

    Guess I might try setting up an activity with a 1 minute ‘screen off’ timer too, so I can stay on stable for once :)

  2. Thanks a lot for fixing the Chrome bug, it was really annoying.
    Also, did you talk to the Visual Design Group about the design of the plasmoid when there is an inhibition? Maybe it’s just me but I get the feeling that there shouldn’t be a checkbox when there are icons in the items before and after it.

      1. The design hasn’t really been adjusted to the new look and feel other than new icons and spacing but I’m still quite happy with the overall look and feel. Regarding the checkbox, in the initial draft there was an icon with a switch but we’re not supposed to use switches on the desktop, so I chose this half-baked solution.
        It was my first larger QML contribution and the code shows, anchors hell all over. I’m planning to clean it up at the Plasma sprint and there’s also some VDG people, so let’s see what they think :)

    1. It is still not ideal, however. When you switch to another tab, Chrome releases the inhibition (which is good) but it won’t restore it when you switch back, only when you pause and resume. I filed a bug against Chromium about that.

  3. Wow, look who’s blogging now! Nice blog post.

    Thanks Kai for taking responsibility over KDE’s entire power stack. Also, I know you have helped a lot on Plasma (especially the battery widget). Keep up the great work.

    Also do/can you recommend tools like tlp or jupiter to save battery life?

  4. Well done.
    The plasmoid is beautiful and elegant, only one functionality seem missing: in kde4 there are a checkbox to disable power management. It’s very useful when I’m on battery and I’m connected with ssh with some server and I wont that my laptop suspend after 5 minute or I need my screen always powered on for monitoring activity.

    And please, read some email :) (you have a nice number of unread message)

  5. Please don’t make notifications about mouse battery being low. People will know it when their mouse dies.
    It’s like the printers that tell you there is no more ink, but the prints are perfekt and it does at least 100 prints before it’s actually out. Those messages are a disservice.
    it is an art not to disturb people with technical problems about all things that could go wrong.
    Another thing is the environmental impact you have if you throw 20% of a non-rechargeable battery away. KDE is used by millions of users.
    But I just to be clear I feel like saying, VERY cool work you do on KDE! :-)

    1. Are you serious right now? Just turn off the notification if it bothers you. About it being default. We may as well turn off the notification about low laptop battery who cares if your laptop is going to suspend/turn off in a minute, right?
      About throwing the batteries away. Well easy. Just add to the notification note “please remember to recycle your old batteries”. Problem solved.

    1. Just uncheck the “Enable Power Management” checkbox in battery monitor, it will disable everything.

  6. I am lost in the pile of bug reports about KDE power management undesired screen dimming during video playback.

    Kai Uwe, could you post the bug number about you fixing the nasty Chrome inhibition bug in Powerdevil you mentioned in your post?

    Any chance of commiting for 4.11? It’s really annoying.

    Thank you!

  7. In other semi-relevant news, I’ve found my batteries are happier with Plasma 5 than never before. Plasma 5 is a lot easier on the system than KDE4, and it shows.

    Thanks for keeping this area maintained.

  8. Did you change anything related to idle time calculation? Since the update to 5.3 my wetab does not auto-suspend nor dim the screen.

    Manual suspending and screen dimming functions very well. The battery/AC change is also detected (the icon shows that). And on my laptop everything works as expected. The wetab is a quite underpowered intel atom computer, so maybe the idle time threshold is not reached due to constant minimal computing of processes. How can I test powerdevil auto suspend and dimming functions?

    Background processes are nothing special (arch). I have twofing (touchpad daemon) and xrandr-align (screen rotation daemon) running. But it also happens with both being disabled.

    1. PowerDevil just uses KIdleTime to track user activity, perhaps there’s an issue in there, please head over to https://bugs.kde.org/ and file a bug report against it, so its maintainers, who know its internals better, can have a look.

  9. Nice to have – sometimes. Like watching a movie.

    I was shocked to find my screen not dimming or locking with no entertainment sites in site.

    Allowing any website to inhibit power management without any way to turn it off is really well .. frankly … dumb.

    There are sites requesting this “feature” (bug) that are not movies or anything entertainment related (in my case a bank login site). If you leave the tab alive in chrome even if not switched to that tab, powerdevil inhibits power management – which is already a security issue (screen lock never turns on). Screen saver never turns on – so screen burns brightly when you don’t want it to. Worse, this may prevent a battery laptop from sleeping which could cause data loss or worse. To find it I had to close tabs one at a time – until i found the one causing powerdevil to be inhibited – which is annoying and extremely user unfriendly.

    Please provide a scheme to disable this “feature”.


  10. Is there a way to configure how powerdevil initiates or handles suspend-to-ram and resume – namely the scripts that are called? It doesn’t seem to use pm-utils and its scripts (/etc/pm/sleep.d/… (on Ubuntu 15.10). [Motivation is that I need a workaround to set hdparm values because apm and apm_battery value from /etc/hdparm.conf don’t get set correctly after resume.]
    So if there was a way to tell powerdevil to call a script on resuming, that would be of great help.
    And thanks for the good work!

    1. PowerDevil uses logind to suspend and that also provides a DBus signal when the system is about to suspend or when it woke up. I could perhaps add a “Run on wake up” option to the Script thing but I suppose (hope) there are other means to run scripts with logind but I don’t know right now, sorry.

  11. Hey :) What do you think about a checkbox beside the program that inhibits power management, whether that inhibition should be allowed or not? I’d really like that feature when watching twitch streams to go to sleep, it would allow the computer to shut down if i don’t jiggle the mouse with kdeconnect when the screen blanking goes of.

Leave a Reply

Your email address will not be published. Required fields are marked *