Summary: | PowerDevil should tell systemd not to handle events like «lid closed» or «power button pressed» in a KDE session. | ||
---|---|---|---|
Product: | [Unmaintained] solid | Reporter: | Nikita Skovoroda <chalkerx> |
Component: | powermanagement-daemon | Assignee: | Lukáš Tinkl <lukas> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | arekm, bastian.beischer, kevin.kofler, lukas, rdieter, scarpino |
Priority: | NOR | ||
Version: | 4.9.2 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
URL: | http://lists.freedesktop.org/archives/systemd-devel/2012-September/006604.html | ||
See Also: | https://bugzilla.redhat.com/show_bug.cgi?id=859227 | ||
Latest Commit: | http://commits.kde.org/kde-workspace/c9e66006e6b2bc4176e9b475b2c7d5e40c180133 | Version Fixed In: | 4.9.3 |
Sentry Crash Report: | |||
Attachments: | tentative patch to store the fd |
Description
Nikita Skovoroda
2012-09-25 22:27:20 UTC
> "handle-power-key:handle-sleep-key:handle-lid-switch" I'm not sure if it should be "handle-power-key:handle-sleep-key:handle-lid-switch" , "handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch" or even "handle-power-key:handle-sleep-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch". http://www.freedesktop.org/wiki/Software/systemd/inhibit is unclear to me in that part. Ok, the page got updated: http://www.freedesktop.org/wiki/Software/systemd/inhibit?action=diff&rev1=29&rev2=30 The correct string is "handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch". Thanks! Will this fix be available in 4.9.2? > Version Fixed In : 4.9.2
Ah, missed that.
Thanks!
Does not work in 4.9.2. Logs say «kded(1045) PowerDevil::PolicyAgent::onSessionHandlerRegistered: systemd powersave events handling inhibited», but no effect. Still double suspending, «systemd-inhibit --list» is empty. Running systemd-inhibit manually works as expected (and populates «systemd-inhibit --list»). … PowerDevil::BackendLoader::loadBackend: Loading UPower backend... PowerDevil::BackendLoader::loadBackend: Success! KDEDPowerDevil::init: Backend loaded, loading core PowerDevil::Core::loadCore: Core loaded, initializing backend PowerDevilUPowerBackend::brightness: Screen brightness: 100 PowerDevilUPowerBackend::init: current screen brightness: 100 PowerDevilUPowerBackend::init: Can suspend PowerDevilUPowerBackend::init: Can hibernate PowerDevil::Core::onBackendReady: Backend is ready, KDE Power Management system initialized PowerDevil::Core::onDeviceAdded: A new battery was detected PowerDevil::PolicyAgent::onSessionHandlerRegistered: Session path: "/org/freedesktop/login1/session/c1" PowerDevil::PolicyAgent::onSessionHandlerRegistered: ACTIVE SESSION PATH: "/org/freedesktop/login1/session/c1" PowerDevil::PolicyAgent::onActiveSessionChanged: Current session is now active PowerDevil::PolicyAgent::onSessionHandlerRegistered: systemd powersave events handling inhibited PowerDevil::PolicyAgent::onSessionHandlerRegistered: systemd support initialized PowerDevil::PolicyAgent::onActiveSessionChanged: Current session is now active PowerDevil::PolicyAgent::onSessionHandlerRegistered: ConsoleKit support initialized PowerDevil::ActionPool::init: Got a valid offer for "DPMSControl" … Wait a moment. I just looked at the code. Where is the file descriptor that is meant to be stored? > http://commits.kde.org/kde-workspace/03a27e496a178a6aeeca23e53b52f4d87cd0fbef
This commit does not store anything!
It was fine when it was on the reviewboard.
/Ok, seems like we'll have to wait a month until 4.9.3.
You can put «systemd-inhibit --what=handle-lid-switch:handle-power-key:handle-suspend-key:handle-hibernate-key sleep 9999d» in KDE autostart (not bash autostart!) as a workaround. Created attachment 74314 [details]
tentative patch to store the fd
Attached is a patch to store the fd, hopefully it fixes the inhibition
[ltinkl@goblin ~]$ systemd-inhibit --what=handle-lid-switch:handle-power-key:handle-suspend-key:handle-hibernate-key sleep 9999d Failed to inhibit: Invalid argument The workaround doesn't seem to work with older systemd versions, although the command is present Workaround is intended to newer systemd versions (191 or later). On older systemd versions it's just not needed, there is no issue to work-around. This whole thing is about something that was introduced in systemd 191. KDE + systemd 190 or lower (with out-of-the-box configurations) works ok with no issues. KDE + systemd 191 or higher (with out-of-the-box configurations) has an issue described in this bug, that can be worked-around with #c11 until it is fixed in newer KDE version (hope it'll be 4.9.3). So, it's perfectly ok if the work-around doesn't work with older KDE versions — it's just not needed. Btw, https://bugzilla.redhat.com/show_bug.cgi?id=859227 should be reopened too. I'm more interested in knowing whether the attached patch works for you :) I'll test it today (in my timezone), when i'll get home. Thanks. Git commit a18b78d7da8cb8d627ad2e85f666bfcf1a2721e1 by Lukas Tinkl. Committed on 05/10/2012 at 11:57. Pushed by lukas into branch 'KDE/4.9'. store the filedescriptor in a member variable make systemd-inhibit work as intended, PowerDevil now handles power/sleep/lid buttons as intended M +6 -3 powerdevil/daemon/powerdevilpolicyagent.cpp M +2 -0 powerdevil/daemon/powerdevilpolicyagent.h http://commits.kde.org/kde-workspace/a18b78d7da8cb8d627ad2e85f666bfcf1a2721e1 Git commit 29a65c6f984f3bcb5792b0b89061e45c925bbe7a by Lukas Tinkl. Committed on 05/10/2012 at 11:57. Pushed by lukas into branch 'master'. store the filedescriptor in a member variable make systemd-inhibit work as intended, PowerDevil now handles power/sleep/lid buttons as intended M +6 -3 powerdevil/daemon/powerdevilpolicyagent.cpp M +2 -0 powerdevil/daemon/powerdevilpolicyagent.h http://commits.kde.org/kde-workspace/29a65c6f984f3bcb5792b0b89061e45c925bbe7a Sorry for the late comment. Yes, the patched version works fine, thanks! Hey, Indeed the patch helps, but when I'm still running into the same issue _sometimes_. I think it has to do with disconnecting the AC cord or swichting activities (and the associated power devil configuration)... Because it works fine when I first boot into my system, login and then suspend/resume. But after I worked for a while I took my laptop out of the docking station so that the battery was not charging anymore, of course power devil switches the power saving configuration then and when I suspend then it still immediately resuspends after waking up... Interesting... so it looks like systemd cookie (stored in a file descriptor) goes away after the resume, so we need to recreate it Git commit 80e9e6e48ff5b84962f3a8543ee06bcd4f122623 by Lukáš Tinkl. Committed on 30/10/2012 at 11:32. Pushed by lukas into branch 'KDE/4.9'. move systemd inhibition initialization to a slot and call it on resume. It looks like the filedescriptor goes away when you suspend so we need to recreate it. M +4 -2 powerdevil/daemon/powerdevilcore.cpp M +27 -17 powerdevil/daemon/powerdevilpolicyagent.cpp M +2 -0 powerdevil/daemon/powerdevilpolicyagent.h http://commits.kde.org/kde-workspace/80e9e6e48ff5b84962f3a8543ee06bcd4f122623 Git commit c9e66006e6b2bc4176e9b475b2c7d5e40c180133 by Lukáš Tinkl. Committed on 30/10/2012 at 11:32. Pushed by lukas into branch 'master'. move systemd inhibition initialization to a slot and call it on resume. It looks like the filedescriptor goes away when you suspend so we need to recreate it. M +4 -2 powerdevil/daemon/powerdevilcore.cpp M +27 -17 powerdevil/daemon/powerdevilpolicyagent.cpp M +2 -0 powerdevil/daemon/powerdevilpolicyagent.h http://commits.kde.org/kde-workspace/c9e66006e6b2bc4176e9b475b2c7d5e40c180133 Hey Lukas, I still have problems. Maybe my logind config file is not set correctly? Here's what I have (systemd version is 195): #HandlePowerKey=poweroff #HandleSuspendKey=suspend #HandleHibernateKey=hibernate #HandleLidSwitch=suspend #PowerKeyIgnoreInhibited=no #SuspendKeyIgnoreInhibited=no #HibernateKeyIgnoreInhibited=no LidSwitchIgnoreInhibited=no Note that the default for LidSwitchIgnoreInhibited is yes. To my understanding that would mean that systemd will not accept the inhibit issued by KDE for lid switch events? My problems appear when I have the AC cord attached and then close the lid. System will suspend. Then I remove the cord and open the lid. System will immediately resuspend. After I wake up from that second suspend powerdevil has set the profile to battery mode and then once I close and open the lid again it will again resuspend immediately. Am I doing something wrong? Try to set the option to the default (yes), otherwise I'm out of ideas as to what could cause this >
> Note that the default for LidSwitchIgnoreInhibited is yes. To my
> understanding
> that would mean that systemd will not accept the inhibit issued by KDE for
> lid
> switch events?
>
Wrong.
The LidSwitchIgnoreInhibited parameter is not related to inhibiting the
«lid close» event, but, instead, it tells systemd to ignore suspend (not
key events) inhibits when the lid close event is not inhibited and handeled
by systemd itself.
For example, when HandleLidSwitch={action} and
LidSwitchIgnoreInhibited=yes, when {action} is inhibited, the lid switch is
not inhibited and the lid is closed, the {action} inhibitor is ignored, and
the {action} is called.
You better leave default values there.
With this patch I'm unable to get my systemd manage lid key (instead of kde). Unchecking "handle button events" doesn't help. systemd still gets information that PowerDevil manages lid events. Could this also be fixed, so there is a choice for a user? No, this is exactly as designed. Unchecking "handle button events" means, you want button events to not get handled at all. It has always meant that. We do not let systemd handle the event because it does not honor KDE settings. And now KDE doesn't honor user desires. I really want my systemd to handle events (like lid closing) and not KDE. I have custom systemd scripts that do many things on suspend and resume. There should be a way for user to get desired behaviour. Could some setting for that be added? Like "Allow systemd to handle button events" Those custom scripts should still be firing, because PowerDevil uses systemd to perform the actual suspend/resume, IF suspending is what you're asking PowerDevil to do. |