Summary: | [systemd] System powers off when sleep button is pressed instead of going to sleep | ||
---|---|---|---|
Product: | [Plasma] Powerdevil | Reporter: | Szőts Ákos <szotsaki> |
Component: | general | Assignee: | Plasma Bugs List <plasma-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | aspotashev, boingo-00, kde, kde, magiblot, nate, nicolas.fella, rdieter, silvan.calarco, zawertun |
Priority: | NOR | ||
Version: | 5.21.0 | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/powerdevil/commit/2d56fc5b4ae61021a7522196a00a4b6697bac80a | Version Fixed In: | 5.22 |
Sentry Crash Report: | |||
Attachments: |
tmp.patch
Screenshot_20210430_235239.png powerdevil-5.21.5-fallback-to-xdg_session_id.patch powerdevil-5.21.5-get_session-auto.patch |
Description
Szőts Ákos
2021-02-21 21:44:58 UTC
Looks like PowerDevil isn't running in systemd boot mode for some reason, can you check if it is? Can you check in both "ps ux" and " systemctl --user status plasma-powerdevil.service " It seems it is running: $ systemctl --user status plasma-powerdevil.service ● plasma-powerdevil.service - Powerdevil Loaded: loaded (/usr/lib/systemd/user/plasma-powerdevil.service; static) Active: active (running) since Sun 2021-02-21 22:30:45 CET; 8h ago Main PID: 1702 (org_kde_powerde) CGroup: /user.slice/user-1000.slice/user@1000.service/background.slice/plasma-powerdevil.service └─1702 /usr/lib64/libexec/org_kde_powerdevil febr 21 22:30:45 openSUSE systemd[1491]: Starting Powerdevil... febr 21 22:30:45 openSUSE systemd[1491]: Started Powerdevil. $ ps aux| grep power root 88 0.0 0.0 0 0 ? I febr21 0:00 [kworker/12:0-events_freezable_power_] root 127 0.0 0.0 0 0 ? I febr21 0:00 [kworker/12:1-events_freezable_power_] root 1095 0.0 0.0 0 0 ? I febr21 0:00 [kworker/0:2-events_power_efficient] aki 1702 0.0 0.2 400584 43340 ? Ssl febr21 0:00 /usr/lib64/libexec/org_kde_powerdevil root 1714 0.0 0.0 246976 10100 ? Ssl febr21 0:00 /usr/libexec/upower/upowerd root 10472 0.0 0.0 0 0 ? I 07:00 0:00 [kworker/0:0-events_power_efficient] In the logs I cannot find anything related: journalctl -u plasma-powerdevil.service -- Logs begin at Fri 2020-06-12 14:50:46 CEST, end at Mon 2021-02-22 07:16:52 CET. -- -- No entries -- It seems that powerdevil logs (journalctl | grep powerdevil) are the same with and without systemd. Without systemd: febr 21 22:27:36 openSUSE dbus-daemon[710]: [system] Activating service name='org.kde.powerdevil.discretegpuhelper' requested by ':1.28' (uid=1000 pid=1757 comm="/usr/lib64/libexec/org_kde_powerdevil ") (using servicehelper) febr 21 22:27:36 openSUSE dbus-daemon[710]: [system] Successfully activated service 'org.kde.powerdevil.discretegpuhelper' febr 21 22:27:36 openSUSE dbus-daemon[710]: [system] Activating service name='org.kde.powerdevil.chargethresholdhelper' requested by ':1.28' (uid=1000 pid=1757 comm="/usr/lib64/libexec/org_kde_powerdevil ") (using servicehelper) febr 21 22:27:36 openSUSE dbus-daemon[710]: [system] Successfully activated service 'org.kde.powerdevil.chargethresholdhelper' febr 21 22:27:36 openSUSE dbus-daemon[710]: [system] Activating service name='org.kde.powerdevil.backlighthelper' requested by ':1.28' (uid=1000 pid=1757 comm="/usr/lib64/libexec/org_kde_powerdevil ") (using servicehelper) febr 21 22:27:36 openSUSE backlighthelper[1853]: org.kde.powerdevil: no kernel backlight interface found febr 21 22:27:36 openSUSE dbus-daemon[710]: [system] Successfully activated service 'org.kde.powerdevil.backlighthelper' febr 21 22:27:36 openSUSE dbus-daemon[1533]: [session uid=1000 pid=1533] Activating service name='org.kde.KScreen' requested by ':1.21' (uid=1000 pid=1757 comm="/usr/lib64/libexec/org_kde_powerdevil ") With systemd: febr 21 22:29:29 openSUSE dbus-daemon[684]: [system] Activating service name='org.kde.powerdevil.discretegpuhelper' requested by ':1.25' (uid=1000 pid=1684 comm="/usr/lib64/libexec/org_kde_powerdevil ") (using servicehelper) febr 21 22:29:29 openSUSE dbus-daemon[684]: [system] Successfully activated service 'org.kde.powerdevil.discretegpuhelper' febr 21 22:29:29 openSUSE dbus-daemon[684]: [system] Activating service name='org.kde.powerdevil.chargethresholdhelper' requested by ':1.25' (uid=1000 pid=1684 comm="/usr/lib64/libexec/org_kde_powerdevil ") (using servicehelper) febr 21 22:29:29 openSUSE dbus-daemon[684]: [system] Successfully activated service 'org.kde.powerdevil.chargethresholdhelper' febr 21 22:29:29 openSUSE dbus-daemon[684]: [system] Activating service name='org.kde.powerdevil.backlighthelper' requested by ':1.25' (uid=1000 pid=1684 comm="/usr/lib64/libexec/org_kde_powerdevil ") (using servicehelper) febr 21 22:29:29 openSUSE backlighthelper[1773]: org.kde.powerdevil: no kernel backlight interface found febr 21 22:29:29 openSUSE dbus-daemon[684]: [system] Successfully activated service 'org.kde.powerdevil.backlighthelper' febr 21 22:29:29 openSUSE dbus-daemon[1494]: [session uid=1000 pid=1494] Activating service name='org.kde.KScreen' requested by ':1.23' (uid=1000 pid=1684 comm="/usr/lib64/libexec/org_kde_powerdevil ") febr 21 22:30:07 openSUSE systemd[1477]: plasma-powerdevil.service: Succeeded. I'm having the same issue. I observed that: * After starting a Plasma session, pressing the Power button or closing the laptop lid are not handled by Plasma and result in poweroff/suspension. * After waking up from suspension, the Plasma session handles the Power button and the laptop lid properly. Cannot reproduce FWIW. If you could tell me commands to execute, log locations, or any other clues how to help debugging this, I'd be glad to. Similar bug: https://bugs.kde.org/show_bug.cgi?id=365100. Actually I've already found 2 more similar bugs: https://bugs.kde.org/show_bug.cgi?id=365100 https://bugs.kde.org/show_bug.cgi?id=434153 Seems that bug affects Fedora and openSUSE users. After some debugging I found that `PolicyAgent::setupSystemdInhibition` called only after resume (see: https://invent.kde.org/plasma/powerdevil/-/blob/master/daemon/actions/bundled/suspendsession.cpp#L56). And not called on PowerDevil start. Created attachment 138037 [details]
tmp.patch
I don't think this patch is correct enough but on my PC issue is gone after applying it.
Marking the report as confirmed as it affects multiple users. *** Bug 434153 has been marked as a duplicate of this bug. *** In log I see this: ``` апр 30 23:30:13 fedora org_kde_powerdevil[16323]: org.kde.powerdevil: The session is not registered with systemd ``` So that's why `setupSystemdInhibition()` is not called from https://invent.kde.org/plasma/powerdevil/-/blob/aba840037bb732661ea749d13aa401317a795d00/daemon/powerdevilpolicyagent.cpp#L292. Created attachment 138040 [details]
Screenshot_20210430_235239.png
Reply from org.freedesktop.login1.Manager when doing `systemctl --user restart plasma-powerdevil.service`.
Szőts Ákos, could you please run this script in the konsole and show paste output: ``` dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.GetSessionByPID uint32:$(pgrep konsole) ``` (it should be only 1 konsole running at time of executing this script). At my PC it shows this: ``` Error org.freedesktop.login1.NoSessionForPID: PID 3536 does not belong to any known session ``` So systemd doesn't treat Konsole as part of any user session. Similar check exists in code of powerdevil and it fails every time on Fedora & openSUSE: https://invent.kde.org/plasma/powerdevil/-/blob/aba840037bb732661ea749d13aa401317a795d00/daemon/powerdevilpolicyagent.cpp#L239. The behaviour described above can be simply reproduced on Fedora 34 KDE Live, just start it in the VM and execute dbus-send command. Link to the iso: https://download.fedoraproject.org/pub/fedora/linux/releases/34/Spins/x86_64/iso/Fedora-KDE-Live-x86_64-34-1.2.iso. Created attachment 138154 [details]
powerdevil-5.21.5-fallback-to-xdg_session_id.patch
Patch to fallback session detection by getting value from XDG_SESSION_ID env. variable.
Still want to hear some comments from devs - is it ok that GetSessionByPID not working as expected on Fedora?
It is expected, yes. Using "/auto" as the session path would also work. Created attachment 138156 [details]
powerdevil-5.21.5-get_session-auto.patch
Thanks!
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/50 Git commit d7c1181a5736bc5c6b2585fb0df9065510efcd7c by Yaroslav Sidlovsky. Committed on 05/05/2021 at 11:32. Pushed by ngraham into branch 'master'. GetSessionByPID DBUS call always fails on newer systemd versions GetSessionByPID returns this error: ``` Error org.freedesktop.login1.NoSessionForPID: PID 2469 does not belong to any known session ``` So instead we will get session by calling GetSession("auto"). Tested on Fedora, should also work on openSUSE & KDE Neon. M +1 -1 daemon/powerdevilpolicyagent.cpp https://invent.kde.org/plasma/powerdevil/commit/d7c1181a5736bc5c6b2585fb0df9065510efcd7c Git commit 2d56fc5b4ae61021a7522196a00a4b6697bac80a by Nate Graham, on behalf of Yaroslav Sidlovsky. Committed on 07/05/2021 at 14:46. Pushed by ngraham into branch 'Plasma/5.21'. GetSessionByPID DBUS call always fails on newer systemd versions GetSessionByPID returns this error: ``` Error org.freedesktop.login1.NoSessionForPID: PID 2469 does not belong to any known session ``` So instead we will get session by calling GetSession("auto"). Tested on Fedora, should also work on openSUSE & KDE Neon. (cherry picked from commit d7c1181a5736bc5c6b2585fb0df9065510efcd7c) M +1 -1 daemon/powerdevilpolicyagent.cpp https://invent.kde.org/plasma/powerdevil/commit/2d56fc5b4ae61021a7522196a00a4b6697bac80a |