New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suspend via logind over UPower if available. #4273
Conversation
Nice! I will try to review it today or tomorrow!
|
Oh and you could have used old PR via git push -f if you'd wanted
|
Ah, I haven't used github very much. I didn't know there was a force flag. I realized what was going on with KDE's upstart version check, and I'm fixing the patch. (version 1.11 > version 1.2 but 1.11 < 1.2 numerically. |
@topfs2 Okay, I've fixed the Upstart version check in the branch. |
please DO NOT merge this. Checking the version number with regexes is hackish and the suspend functionality in KDE recently broke because they did the same thing. See this recent discussion on the systemd-devel mailing list: http://lists.freedesktop.org/archives/systemd-devel/2014-February/017399.html One of the systemd devs explains how to properly implement checks like this in the following mail: http://lists.freedesktop.org/archives/systemd-devel/2014-February/017452.html |
Looking at the code (I am the one who rewrote most of the logind stuff last year), I guess the simplest way to do this is, is to call one of the CanXYZ()-Methods (doesn't really matter which I guess, afaik they were all added in the same systemd version, except for HybridSleep maybe) and check whether it returns org.freedesktop.DBus.Error.UnknownMethod. If so, you could assume that the logind version is too old. Maybe there is an even more elegant way to this, I'm no DBus expert. But you really, really should NOT check for the version number. |
Why would they change the Version API like that? Yes, it is generally poor practice to check versions, but people do it, and changing APIs in a stable software like that is also poor practice. I'll update it to call the CanSuspend() and check for a DBus error message. |
@topfs2 for review please |
@topfs2 ping |
gave this a try on ubuntu 14.04 cause I was hoping it'd fix hibernate. Result: hibernate is disabled. |
Odd that it worked before. I dropped the offending dbus_connection_close line. Try it now. |
still produces this error: |
Try it now. The CDBusMessage wrapper class was handling the free of the
|
@wsnipex ping We need to solve those issues as with 15.04 they use logind, but still ship upower and stuff .. bloody mess. |
the change looks good to me, did anyone test it on 15.04 or another logind based distro? |
14.04 is still working as it should with that patch (from Unity). I don't have full blown 15.04 with desktop here, sadly. 2015-04-26 17:38 GMT+02:00 Wolfgang Schupp notifications@github.com:
Fingerprint: 4606 DA19 EC2E 9A0B 0157 C81B DA07 CF63 1A99 5A9B |
jenkins build this please |
I just merged this with tip and tried it with Kubuntu 15.04. It's working. Without it, Kodi doesn't suspend as the UPower CanSuspend calls fail. It looks like Ubuntu stripped that out of UPower. |
Yes, that's the idea behind this approach. |
@MartijnKaijser @FernetMenta this is needed to make hybrid distros happy, e.g. upower available, but stripped down. |
I'd be a bit cautious about adding my change here for those on distros like I think the UPower class needs to check for the CanSuspend call before On Mon, May 4, 2015 at 2:05 AM, Peter Frühberger notifications@github.com
|
Not nice - It seems even upstream does not know at all howto do it properly. And we cannot really workaround every mad thing distributions implemented on their way to systemd. |
What about brute force instead? Load both and send events to all loaded providers? |
That won't work. Both the UPower and the systemd-logind call would trigger On Tue, May 5, 2015 at 9:33 AM, Pär Björklund notifications@github.com
|
what's the status on this? Is it in good shape? |
I haven't had time to look at it until just now. I think the best way to handle this is in xbmc/powermanagement/PowerManager.cpp. I'm going to drop the two patches from this branch, and instead check capabilities of each type. If UPower doesn't support suspend, try the next class until we find one that does. |
Here's a patch that counts the number of available power features on Linux and selects the manager that supports the most. I've only tested this on Kubuntu 15.04 with logind. It successfully tries ConsoleKit + UPower and ConsoleKit + DeviceKit before settling on logind because it supports all of suspend, powerdown, hibernate and reboot. |
looks like a nice solution to me. @topfs2 ping |
I tested this on ubuntu 14.04 and it works fine for me. |
Suspend via logind over UPower if available.
From pull request #4168:
The suspend feature of UPower is deprecated. XBMC supports suspending using systemd-logind, however it defaults to a few other UPower methods first before trying Logind. This patch checks for logind first, and uses it if available.
I've updated the HasLogind() method to make sure systemd is at least version 183, or if the systemd version API is missing, that Upstart is at least version 1.11. This way, XBMC will default to suspending via logind if the version supports suspend. If it does not, it will skip logind and try UPower as before.