Bug 344456

Summary: Plasma 5 desktop does not suspend with only upower, no systemd
Product: [Plasma] Powerdevil Reporter: Eric Hameleers <alien>
Component: generalAssignee: Plasma Development Mailing List <plasma-devel>
Status: RESOLVED UPSTREAM    
Severity: major CC: 2Kmm, adam.mikulic, anton.filimonov, artoo, aspotashev, asturm, bob.mt.wya, cele81, fademind, gentoouser, kde, kde, lukas, manciuleas, manuel, mgraesslin, simonandric5, sokann, stupor_scurvy343
Priority: NOR    
Version: 5.2.2   
Target Milestone: ---   
Platform: Slackware   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: .xsessions-errors: powedevil starts before polkit-kde-authentication-agent-1
environment with kwrapper
environment without kwrapper
Polkit configuration file for suspend/hibernate

Description Eric Hameleers 2015-02-22 18:38:54 UTC
Symptom: The system does not offer suspend or hibernate options, whereas the old KDE 4.x versions that were installed prior to Plasma 5 have always offered shutdown and hibernate options.
Additionally, the laptop can not be left running on battery because it will never suspend and will drain the battery completely.


Reproducible: Always

Steps to Reproduce:
1. Install Slackware-current (Slackware's development tree)
2. Install Plasma 5 packages from http://taper.alienbase.nl/mirrors/alien-kde/current/testing/
3. Run the Plasma 5 desktop

Actual Results:  
In the Leave menu: Shutdown and Hibernate are missing. If a laptop running this software is left alone and on battery power, it will not suspend (thereby preserving battery charge) but instead it will keep running until the battery is drained.

Expected Results:  
In the Leave menu: Shutdown and Hibernate are present.
If the Slackware laptop running Plasma 5 is left unattended while on battery power, it will suspend before the battery is fully drained.

Affected system: Slackware-current (development tree of Feb 2015) combined with Framework 5.7.0, Plasma 5.2.0 and Applications 14.12.2.

Points of interest: Slackware uses upower 0.9.17 and does not have systemd or a shim. It uses ConsoleKit (1, not 2) for session and seat management, and polkit-0.105 for handling the privileges. Additional packages for the KDE 4 and Plasma 5 environments are, polkit-qt-1, polkit-qt5-1, polkit-kde-agent-1, polkit-kde-framework, polkit-kde-kcmodules-1, polkit-kde-kcmodules-framework.

Note: this older version of UPower which Slackware uses, still offers the shutdown and hibernate functionality which was ultimately removed after 0.9.23.
Diagnostics: Here is output of the relevant programs, feel free to ask more detail:
$ upower -d
...
Daemon:
  daemon-version:  0.9.17
  can-suspend:     yes
  can-hibernate    no
  on-battery:      no
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no

$ qdbus  org.kde.kded5 /org/freedesktop/PowerManagement CanSuspend
false

$ qdbus  org.freedesktop.PowerManagement /org/freedesktop/PowerManagement CanSuspend
false

$ qdbus --system org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.CanSuspend
Service 'org.freedesktop.login1' does not exist.
Comment 1 Kai Uwe Broulik 2015-02-22 19:11:33 UTC
Can you check the SuspendAllowed and CanSuspend properties of org.freedesktop.UPower? Both of them have to be true in order for it to announce suspend support.
Comment 2 Eric Hameleers 2015-02-22 20:58:34 UTC
Hi Kai

First: my apologies for stating "shutdown and hibernate" when I meant to say "suspend and hibernate" of course.

Here are the results on my laptop:

$ qdbus --system org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.CanSuspend
true
$ qdbus --system org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.SuspendAllowed
true

And this actually suspended the laptop:
$ dbus-send --system --print-reply  --dest='org.freedesktop.UPower' /org/freedesktop/UPower org.freedesktop.UPower.Suspend
method return sender=:1.14 -> dest=:1.52 reply_serial=2

Still, no suspend option in the Leave menu or in the System Settings > Power Management.
Comment 3 Lukáš Tinkl 2015-02-22 23:34:57 UTC
Are you really sure there's no login1 service on DBUS? It may not be visible but it's activated on first usage.

The code responsible for querying the suspend/hibernate capabilities first tries with login1 and only if that's not available, falls back to upower. It not only checks whether the method is available (CanSuspend) but also whether it's allowed by polkit (SuspendAllowed), see below for the snippet:

   if (m_login1Interface) {
        QDBusPendingReply<QString> canSuspend = m_login1Interface.data()->asyncCall("CanSuspend");
        canSuspend.waitForFinished();
        if (canSuspend.isValid() && (canSuspend.value() == "yes" || canSuspend.value() == "challenge"))
            supported |= ToRam;

        QDBusPendingReply<QString> canHibernate = m_login1Interface.data()->asyncCall("CanHibernate");
        canHibernate.waitForFinished();
        if (canHibernate.isValid() && (canHibernate.value() == "yes" || canHibernate.value() == "challenge"))
            supported |= ToDisk;

        QDBusPendingReply<QString> canHybridSleep = m_login1Interface.data()->asyncCall("CanHybridSleep");
        canHybridSleep.waitForFinished();
        if (canHybridSleep.isValid() && (canHybridSleep.value() == "yes" || canHybridSleep.value() == "challenge"))
            supported |= HybridSuspend;
    } else {
        if (m_upowerInterface->canSuspend() && m_upowerInterface->SuspendAllowed()) {
            qCDebug(POWERDEVIL) << "Can suspend";
            supported |= ToRam;
        }

        if (m_upowerInterface->canHibernate() && m_upowerInterface->HibernateAllowed()) {
            qCDebug(POWERDEVIL) << "Can hibernate";
            supported |= ToDisk;
        }
    }
Comment 4 Eric Hameleers 2015-02-23 09:40:17 UTC
Hi Lukáš,

I am certain that there is no Login1 service available on DBUS. For the moment, Slackware is not prepared to add anything looking like systemd or logind to the distro. We still use ConsoleKit 0.4.5 for session management and may switch to ConsoleKit2 in future.

Eric
Comment 5 Eric Hameleers 2015-02-24 21:44:32 UTC
This is interesting. When opening the systemsettings > powermanagement, and while monitoring DBus calls with dbus-monitor I expected so find calls to org.freedesktop.UPower but instead I see calls to org.freedesktop.PowerManagement and those return false:

method call sender=:1.59 -> dest=org.freedesktop.PowerManagement serial=37 path=/org/freedesktop/PowerManagement; interface=org.freedesktop.PowerManagement; member=CanSuspend
method return sender=:1.4 -> dest=:1.59 reply_serial=37
boolean false
method call sender=:1.59 -> dest=org.freedesktop.PowerManagement serial=38 path=/org/freedesktop/PowerManagement; interface=org.freedesktop.PowerManagement; member=CanHibernate
method return sender=:1.4 -> dest=:1.59 reply_serial=38
boolean false
Comment 6 Kai Uwe Broulik 2015-02-24 21:51:26 UTC
Applications are not supposed to call UPower directly. The FDO interface is standardized and, in our case, provided by PowerDevil.
Comment 7 Eric Hameleers 2015-02-24 22:03:28 UTC
Hi Kai, I understand. But I was trying to indicate the difference (true versus false) of what UPower thinks about ability to suspend and what PowerDevil makes of it.

Is it perhaps caused by solid's configuration? When compiling solid-5.7.0 I noticed:

-- The following features have been disabled:
 * Solid::PowerManagement , WIP: Freedesktop backend for the asyncrhonous api
 * Solid::PowerManagement , WIP: Freedesktop backend for the asyncrhonous api

And I thought, if that gets disabled by default and it is a WIP, it surely is not required for proper working of powerdevil, correct?
Because I also get:
$ qdbus org.kde.Solid.PowerManagement /org/freedesktop/PowerManagement CanSuspend
false

Note that I claim no knowledge of the topic whatsoever, I just try to be as verbose as possible.
Comment 8 Eric Hameleers 2015-02-26 10:10:26 UTC
This must be related to policies somewhere, because when root starts a Plasma 5 session, the Suspend and Hibernate options are present.
What I fail to understand is why this was never an issue in KDE 4 sessions, nor in XFCE. It started happening with Plasma 5. So is PowerDevil evaluating policies differently than before?
Comment 9 Lukáš Tinkl 2015-02-26 12:43:15 UTC
Do you have polkit-kde-authentication-agent-1 running? That would grant you the privs
Comment 10 manciuleas 2015-02-27 21:03:53 UTC
Created attachment 91331 [details]
.xsessions-errors: powedevil starts before polkit-kde-authentication-agent-1
Comment 11 manciuleas 2015-02-27 21:05:35 UTC
Hi Lukas,

I'm trying to help Eric sort out this issue on our Slackware systems.
polkit-kde-authentication-agent-1 is indeed running, but according to my .xsession-errors (attached) it is started by klauncher *after* powerdevil is started by kded. Is this expectect behavior? Otherwise is there a way to change start-up order or inhibit kded to start the services until after klauncher is done?
Comment 12 Lukáš Tinkl 2015-02-27 21:21:27 UTC
Hmm, that could indeed be the problem. polkit-kde-authentication-agent-1 is started by the session which is always after kded modules (powerdevil being one)... 

I wonder what happens when you restart kded (and hence powerdevil's kded module) after the session has been up and running (just killall -9 kded5 && kded5) and then restart plasmashell (kquitapp5 plasmashell && plasmashell)
Comment 13 manciuleas 2015-02-27 22:34:26 UTC
(In reply to Lukáš Tinkl from comment #12)
> Hmm, that could indeed be the problem. polkit-kde-authentication-agent-1 is
> started by the session which is always after kded modules (powerdevil being
> one)... 
> 
> I wonder what happens when you restart kded (and hence powerdevil's kded
> module) after the session has been up and running (just killall -9 kded5 &&
> kded5) and then restart plasmashell (kquitapp5 plasmashell && plasmashell)

Thank you for your quick reply. 
I issued the commands you suggested and that did the trick (partially). Suspend & Hibernate show up in the Leave Menu, Shutdown & Reboot are still missing. 
Now, when powerdevil starts it CAN contact ConsoleKit, whereas in the 'normal' start-up sequence there's an error message about not contacting CK.
Can the start-up sequence be changed from startkde?

kf5.kiconthemes: "Theme tree: (Breeze)"
powerdevil: Loading UPower backend...
powerdevil: Success!
powerdevil: Backend loaded, loading core
powerdevil: Core loaded, initializing backend
powerdevil: Using XRandR
powerdevil: Screen brightness value:  3
powerdevil: current screen brightness value:  3
powerdevil: Can suspend
powerdevil: Can hibernate
powerdevil: Backend is ready, KDE Power Management system initialized
powerdevil: A new battery was detected
XSync seems available and ready
XSync Inited
Supported, init completed
powerdevil: Current session is now active
powerdevil: ConsoleKit support initialized
powerdevil: Got a valid offer for  "DPMSControl"
powerdevil: Core is ready, registering various services on the bus...
powerdevil: Can't contact systemd
powerdevil: We are now into activity  "default"
powerdevil: () ()
powerdevil: () ()
powerdevil: Loading profile for plugged AC
powerdevil: Activity is not forcing a profile
powerdevil: Profiles:  "AC" ""
powerdevil: set screen brightness percentage:  30
powerdevil: Screen brightness value max:  10
powerdevil: set screen brightness value:  3
powerdevil: 
powerdevil: Loading timeouts with  300000
Comment 14 Lukáš Tinkl 2015-03-01 20:50:10 UTC
Adding Martin G. to CC
Comment 15 David Edmundson 2015-03-01 21:01:58 UTC
Can you get the 

/proc/$PID/environ from kded5 both in startup and when restarted.
Comment 16 manciuleas 2015-03-01 22:55:22 UTC
(In reply to David Edmundson from comment #15)
> Can you get the 
> 
> /proc/$PID/environ from kded5 both in startup and when restarted.

Hi David,

At the KDE login prompt (works only as root):
#cat /proc/6931/environ
SHELL=/bin/falseDBUS_STARTER_ADDRESS=unix:abstract=/tmp/dbus-BIa7iG2AwB,guid=475bad861fee482f041c727f54f39599DISPLAY=:0XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0PATH=/bin:/usr/bin:/usr/local/binXDG_VTNR=7XDG_SESSION_TYPE=x11XCURSOR_THEME=DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BIa7iG2AwB,guid=475bad861fee482f041c727f54f39599XDG_SEAT=seat0QT_IM_MODULE=composeXAUTHORITY=/var/run/sddm/:0XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0USER=sddmXDG_SESSION_CLASS=greeterDBUS_STARTER_BUS_TYPE=sessionPWD=/var/lib/sddmLANG=HOME=/var/lib/sddmLOGNAME=sddmroot

After login as normal user:
$cat  /proc/7175/environ
r - (just this one letter)

Atfter restarting using Lukas' command
$cat /proc/7705/environ
CPLUS_INCLUDE_PATH=/usr/lib64/qt/includeXDG_VTNR=7MANPATH=/usr/local/man:/usr/man:/usr/lib64/java/manKDE_MULTIHEAD=falseHOSTNAME=woody.msm.dynu.netSHELL=/bin/bashTERM=xtermXDG_SESSION_COOKIE=305abc5eecc5c06a5956d035532fc488-1425249837.402580-775400545KONSOLE_DBUS_SERVICE=:1.99GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/sebas/.gtkrc-2.0:/home/sebas/.config/gtkrc-2.0KONSOLE_PROFILE_NAME=ShellGS_LIB=/home/sebas/.fontsGTK_RC_FILES=/etc/gtk/gtkrc:/home/sebas/.gtkrc:/home/sebas/.config/gtkrcWINDOWID=140509190QT5DIR=/usr/lib64/qt5SHELL_SESSION_ID=b291dfc267df4000aa624220bcc8b220XDG_SESSION_CLASS=userKDE_FULL_SESSION=trueANT_HOME=/usr/share/antUSER=sebasLS_COLORS=GDK_USE_XFT=1XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0SESSION_MANAGER=local/woody:@/tmp/.ICE-unix/7189,unix/woody:/tmp/.ICE-unix/7189XDG_CONFIG_DIRS=/etc/xdg:/etc/kde/xdgT1LIB_CONFIG=/usr/share/t1lib/t1lib.configMINICOM=-c onPATH=/home/sebas/work/OE/stuff/bitbake/bin:/home/sebas/work/CodeSourcery/Sourcery_G++_Lite/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/share/ant/bin:/usr/lib64/kde4/libexec:/usr/lib64/java/bin:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:/usr/lib64/qt5/bin:.DESKTOP_SESSION=plasmaQT_IM_MODULE=composeLC_COLLATE=CXDG_SESSION_TYPE=x11INPUTRC=/etc/inputrcPWD=/home/sebasJAVA_HOME=/usr/lib64/javaVDPAU_LOG=0KONSOLE_DBUS_WINDOW=/Windows/1KDE_SESSION_UID=1000LANG=en_USKDEDIRS=/usrQT4DIR=/usr/lib64/qtBBPATH=/home/sebas/work/OE/stuff/build:/home/sebas/work/OE/stuff/openembeddedKONSOLE_DBUS_SESSION=/Sessions/1COLORFGBG=15;0XDG_SEAT=seat0SHLVL=2HOME=/home/sebasKDE_SESSION_VERSION=5LANGUAGE=LS_OPTIONS=-F -b -T 0 --color=autoXCURSOR_THEME=breeze_cursorsLESS=-MRXDG_SESSION_DESKTOP=KDELOGNAME=sebasKSDK_PATH=/opt/Freescale/KSDK_1.1.0XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/shareDBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ptZvB0UDfc,guid=e172c04dd00babbdc789f86954f3962dLESSOPEN=|lesspipe.sh %sPKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfigDISPLAY=:0PROFILEHOME=QT_PLUGIN_PATH=/usr/lib64/qt5/plugins:/lib/kde5/plugins/XDG_CURRENT_DESKTOP=KDEG_BROKEN_FILENAMES=1XAUTHORITY=/tmp/xauth-1000-_0_=/usr/bin/kded5

Regards
Comment 17 manciuleas 2015-03-01 23:01:56 UTC
I have noticed that there's also a kded4 running after logging in. Is kded4 still necessary?
The environ for kded4 is:

bash-4.3$ cat /proc/8207/environ 
XDG_VTNR=7CPLUS_INCLUDE_PATH=/usr/lib64/qt/includeMANPATH=/usr/local/man:/usr/man:/usr/lib64/java/manHOSTNAME=woody.msm.dynu.netSHELL=/bin/bashTERM=dumbXDG_SESSION_COOKIE=305abc5eecc5c06a5956d035532fc488-1425250685.73213-1277521160GS_LIB=/home/sebas/.fontsQT5DIR=/usr/lib64/qt5KDE_FULL_SESSION=trueXDG_SESSION_CLASS=userANT_HOME=/usr/share/antUSER=sebasLS_COLORS=GDK_USE_XFT=1XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0XDG_CONFIG_DIRS=/etc/xdg:/etc/kde/xdgT1LIB_CONFIG=/usr/share/t1lib/t1lib.configMINICOM=-c onDESKTOP_SESSION=plasmaPATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/share/ant/bin:/usr/lib64/kde4/libexec:/usr/lib64/java/bin:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:/usr/lib64/qt5/bin:.LC_COLLATE=CXDG_SESSION_TYPE=x11PWD=/home/sebasINPUTRC=/etc/inputrcJAVA_HOME=/usr/lib64/javaVDPAU_LOG=0KDE_SESSION_UID=1000LANG=en_USKDEDIRS=/usrQT4DIR=/usr/lib64/qtHOME=/home/sebasXDG_SEAT=seat0SHLVL=1KDE_SESSION_VERSION=5XCURSOR_THEME=breeze_cursorsLS_OPTIONS=-F -b -T 0 --color=autoLOGNAME=sebasXDG_SESSION_DESKTOP=KDELESS=-MRDBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9gnDo32AKV,guid=12a9aa4028b4ff3a737d34f654f3997dXDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/shareKSDK_PATH=/opt/Freescale/KSDK_1.1.0LESSOPEN=|lesspipe.sh %sPKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfigDISPLAY=:0QT_PLUGIN_PATH=/usr/lib64/qt5/plugins:/lib/kde5/plugins/XDG_CURRENT_DESKTOP=KDEG_BROKEN_FILENAMES=1XAUTHORITY=/home/sebas/.Xauthority_=/usr/bin/kwrapper5SESSION_MANAGER=local/woody:@/tmp/.ICE-unix/8152,unix/woody:/tmp/.ICE-unix/8152QT_IM_MODULE=composeQT_NO_GLIB=1QT_QPA_PLATFORM=xcbLANGUAGE=

and at the same time as mentioned in the previous comment for kded5 I get:
bash-4.3$ cat /proc/8136/environ 
r

Regards
Comment 18 manciuleas 2015-03-05 21:14:43 UTC
Hi,

Are there any updates on this bug? Is more information necessary?
Thank you.
Comment 19 Eric Hameleers 2015-03-29 11:36:13 UTC
(In reply to Lukáš Tinkl from comment #12)
> Hmm, that could indeed be the problem. polkit-kde-authentication-agent-1 is
> started by the session which is always after kded modules (powerdevil being
> one)... 
> 
> I wonder what happens when you restart kded (and hence powerdevil's kded
> module) after the session has been up and running (just killall -9 kded5 &&
> kded5) and then restart plasmashell (kquitapp5 plasmashell && plasmashell)

On my laptop, suspend and hibernate will indeed appear after killing kded5 and restarting plasmashell.

You will get shutdown & reboot back by editing /usr/bin/startkde and changing the line:
    kwrapper5 ksmserver $KDEWM $KSMSERVEROPTIONS
to
    ksmserver $KDEWM $KSMSERVEROPTIONS
i.e. by removing the "kwrapper5". Making this edit by itself will not change anything with regard to suspend/hibernate, they are two separate issues.
Comment 20 stupor_scurvy343 2015-04-09 14:28:50 UTC
(In reply to Eric Hameleers from comment #19)
> You will get shutdown & reboot back by editing /usr/bin/startkde and
> changing the line:
>     kwrapper5 ksmserver $KDEWM $KSMSERVEROPTIONS
> to
>     ksmserver $KDEWM $KSMSERVEROPTIONS
> i.e. by removing the "kwrapper5".

I can confirm that removing kwrapper causes shutdown/reboot entries to reappear. It turns out that launching ksmserver with kwrapper5 causes org.freedesktop.ConsoleKit.Manager.CanStop to return false. Not really sure what the cause of that could be.
Comment 21 David Edmundson 2015-04-09 14:31:34 UTC
I have a theory. 
Console Kit sets a an environment variable which possibly isn't being transferred.

Can you cat /proc/PIDofKSMServer/environment 

both with and without kwrapper5 and attach results
Comment 22 stupor_scurvy343 2015-04-09 15:02:50 UTC
Created attachment 91963 [details]
environment with kwrapper
Comment 23 stupor_scurvy343 2015-04-09 15:03:27 UTC
Created attachment 91964 [details]
environment without kwrapper
Comment 24 stupor_scurvy343 2015-04-09 15:05:22 UTC
Note that the environment with kwrapper is from "kwrapper5 ksmserver" and "ksmserver [kdeinit5]" has none.
Comment 25 artoo 2015-04-24 18:11:29 UTC
Hi Eric,

the part with the missing restart/shutdown in the menu, can be also solved by providing polkit rules for ck restart/shutdown.

Polkit rules for upower make also suspend/hibernate appear in menu.
But, I do get on gentoo the very same errors logged regarding powerdevil not registering a ck session, thus no suspend.
Comment 26 Eric Hameleers 2015-05-10 15:07:02 UTC
Created attachment 92523 [details]
Polkit configuration file for suspend/hibernate

If this file is added to /etc/polkit-1/localauthority/50-local.d/ (for instance as "30-org.freedesktop.upower.pkla") it will enable the missing Suspend and Hibernate options in the Plasma 5 desktop.
Comment 27 Eric Hameleers 2015-05-10 15:12:58 UTC
I have attached a polkit file which enables the missing suspend/hibernate features in my Plasma 5 desktop.
Thanks to luis' comment in this blog article: http://alien.slackbook.org/blog/kde-5_15-02-release-for-slackware-current/
I want to suggest that this bug report can be closed now that there is a working solution.

In that same article, two other polkit files are proposed to enable the missing shutdown/rebootfeatures without the need for removing the kwrapper5 command from the KDE startup script "/usr/bin/startkde".
For your reference, this is the content of those two files.
Note that i have altered them slightly compared to the proposals in my blog, because I want to limit this functionality to users in the "power" group:

cat /etc/polkit-1/localauthority/50-local.d/40-org.freedesktop.consolekit.system.stop-multiple-users.pkla
[Allow power users to shutdown]
Identity=unix-group:power
Action=org.freedesktop.consolekit.system.stop-multiple-users;org.freedesktop.consolekit.system.stop
ResultAny=yes
ResultInactive=no
ResultActive=yes

cat /etc/polkit-1/localauthority/50-local.d/41-org.freedesktop.consolekit.system.restart-multiple-users.pkla
[Allow power users to restart]
Identity=unix-group:power
Action=org.freedesktop.consolekit.system.restart-multiple-users;org.freedesktop.consolekit.system.restart
ResultAny=yes
ResultInactive=no
ResultActive=yes
Comment 28 Kai Uwe Broulik 2015-05-10 15:18:58 UTC
Thanks for your feedback and support!
Comment 29 Manuel Bärenz 2015-08-18 16:25:33 UTC
*** Bug 351447 has been marked as a duplicate of this bug. ***
Comment 30 Manuel Bärenz 2015-08-18 19:34:22 UTC
For Gentoo, just adding the Polkit files will not suffice. Only after respawning first kded5 and then plasmashell am I able to see Sleep and Hibernate buttons at all. And even then the Sleep button does not work, but only locks the screen after showing a black screen for a few seconds.
Comment 31 gentoouser 2015-11-22 11:38:56 UTC
I had the same problem as Manuel on my gentoo box. Even after adding the Polkit files nothing changed, both shutdown/reboot and sleep/hibernate options were not shown.
In my case the reason was that my user was not a member of the group "users". When I added my user account to this group, everything was OK.
Comment 33 adam.mikulic 2015-12-18 17:33:20 UTC
I still have this problem. I'm running gentoo with openrc (no systemd), all software in current versions to this time, however there is some progress since recent time when parts of kde5 was upgraded that I see restart and shutdown options. I've tried everything from this thread except restarting kded5 and powerdevil from running session, removing kwrapper from startkde doesn't help, I was always member of group "users", polkit rules are in place, all dbus commands have same output as in this thread and I have a right to suspend as a user. However my system don't support hibernate, I hope this is not a problem. Maybe the problem is that powerdevil can't contact consolekit daemon.

 .xsession-errors
powerdevil: Can't contact systemd
powerdevil: Can't contact ck
Comment 34 Kai Uwe Broulik 2015-12-18 17:52:36 UTC
Check whether the dbus service org.freedesktop.ConsoleKit is running and it has permission to access it. That message is from the inhibition manager and unrelated to suspend, though.
Comment 35 adam.mikulic 2015-12-18 18:19:33 UTC
I believe so, it returns this:

qdbus --system org.freedesktop.ConsoleKit
/
/org
/org/freedesktop
/org/freedesktop/ConsoleKit
/org/freedesktop/ConsoleKit/Manager
/org/freedesktop/ConsoleKit/Seat1
/org/freedesktop/ConsoleKit/Session2

I've tried with fresh new user and it is still the same. Only difference is that new user when click restart (restart computer) only X session is actually restarted, this user is only member of "users" group, while my actual user is member of more groups. I see that slackware and gentoo are using different groups power and users, and that user above who has reported same symptoms resolved it by adding user to group "users". Maybe I have some group rights wrong somewhere in filesystem, process, socket, anything, or is is solely a way for authorization by those polkit rules? Is there any way to debug why powerdevil can't contact consolekit?
Comment 36 Andreas Sturmlechner 2016-01-30 16:31:38 UTC
Please check your consolekit setup w/ '$ ck-list-sessions' from inside your plasma session.

Make sure your system-login file is valid:
https://wiki.gentoo.org/wiki/KDE/Plasma_5_upgrade#Missing_shutdown.2C_reboot.2C_suspend_and_hibernate_buttons_when_using_OpenRC
Comment 37 adam.mikulic 2016-01-31 10:06:42 UTC
$ ck-list-sessions
Session2:
        unix-user = '1000'
        realname = '(null)'
        seat = 'Seat1'
        session-type = ''
        active = TRUE
        x11-display = ':0'
        x11-display-device = '/dev/tty7'
        display-device = ''
        remote-host-name = ''
        is-local = TRUE
        on-since = '2016-01-31T09:53:12.970020Z'
        login-session-id = ''

I believe I have everything right regarding https://wiki.gentoo.org/wiki/KDE/Plasma_5_upgrade#Missing_shutdown.2C_reboot.2C_suspend_and_hibernate_buttons_when_using_OpenRC
Comment 38 Anton Filimonov 2016-04-13 07:31:42 UTC
Had same problem with suspend in Gentoo with plasma 5.5.5. Localauthority files mentioned above didn't help. Managed to solve missing suspend issue by adding polkit rule instead:

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.upower.suspend")
    {
        return polkit.Result.YES;
    }
});
Comment 39 adam.mikulic 2016-10-16 14:29:26 UTC
Hi, I'm happy to report that the problem seems to be finally fixed with plasma 5.8 (just confirmed by my experience, not changelog).