Thursday 17 October 2013

More power management changes

As is becoming common, we will have some more power management changes in GNOME 3.12, though those changes will also affect other desktops, whether they use UPower's D-Bus interface, or libupower-glib, the helper library.

The goals of the exercise were simple:

  • reduce wake-ups on the daemon and on the client side
  • reduce code duplication amongst desktop environments, and even within the same environment (composite battery, anyone?)
  • moving some policy actions to a lower level (one could not request hibernation or suspend when multiple users were logged in without interaction and passwords)
All those changes are now in UPower master ready for testing.

Out with the old

The deprecated interfaces for Suspend, Hibernate, etc. are finally removed, after being obsoleted by logind. We've also removed the QoS interface that nobody was using, and the out-dated battery recall support. It's not that batteries don't explode any more, it's that they don't all come from known-bad batches.

In with the new

We have 2 new properties on each of the devices.

WarningLevel which uses daemon-side configurations to tell you whether a device's battery level is low, critically low, or whether we're about to take action on that critical level.

We also have IconName, which replaces some cut'n'pasted code between desktop components. If your desktop environment has many more icons for all types of devices on low battery, for example, you can ignore this property and use the code you always have.

Using those new properties usefully is the new DisplayDevice object. It groups all the batteries and UPSes in the daemon into one, easy to use object that you can use to display a single status icon in your shell chrome. Obviously, if you want to show more devices, the individual batteries and UPSes are still available through the usual means. And it obviously has the 2 new properties mentioned above, so your session daemon can get told when to show notifications for low batteries.

And finally, using that new combined DisplayDevice is the critical battery action policies. As mentioned above, multi-user systems could not hibernate without requiring the user to enter an administrator password, which is less than convenient when your machine is running out of UPS power fast. The configuration for that policy is now in the daemon itself, with sane defaults, and it will hibernate the machine for you.

And to the modernisation

libupower-glib now uses GDBus, even if the daemon doesn't. The daemon however sends PropertiesChanged signals which means that modern D-Bus bindings will automatically get the new values for properties, instead of polling the daemon. The DeviceChanged and Changed signals have thus been removed.

API changes

They are numerous, too many to mention here. I've posted to the device-kit mailing-list with a list of changes that were made, reply there if you have any questions regarding using UPower in your application or session daemons.


systemd >= 207 will save your brightness settings across reboots, and the upcoming systemd 209 will have support for saving keyboard backlight across reboots.

I've made attempts at supporting Intel Rapid Start in systemd, but this will actually require kernel changes. Hopefully we should be able to land this by the time GNOME 3.12 is released.


Kevin Krammer said...

Please excuse me if this is a stupid question but why would users of either the D-Bus interface or the glib abstraction library be affected?

Affected in such a context has a negative vibe attached to it. Like having to change their code.

Bastien Nocera said...

Affected doesn't necessarily have a negative connotation, it can just mean "it will change something in the subject".

It breaks the D-Bus API, and both the ABI and API of the libupower-glib helper library, so it has a negative influence. It adds badly needed features, so will have a positive influence as well :)

Anonymous said...

Hi, I am facing a problem with the "HybridSleep"-thing in UPower, so I set it to "Hibernate" in UPower.conf, but after reloading the upower-systemd.unit I still get critical-action: HybridSleep from upower -d . So I had a look into your code and didn't find a trace where this Parameter is read.

And now I want to say why I don't want HybridSleep as default. My Thinkpad X1 cannot do resume from sleep aka standby anymore (some kind of hardware problem). HybridSleep would be the best option, if my hardware would still function correctly, but I am forced to use hibernate only. For now this issue is not critical because I do not loose any data in the process. I can still resume from hibernate even if the UPower has used HybridSleep after I switch off the notebook while in sleep manually.

And yes, I know, the method up_backend_take_action(...) calls logind to do the actual sleeping and hibernating.

Besides all of this, I have a pretty standard Gnome 3.12 desktop on Gentoo. I apologize for reporting this here instead in a bugzilla of yours, because I am not sure, if I missed something in your code which makes my statements invalid. Any hints are welcome.

Bastien Nocera said...

André K: it probably doesn't use Hibernate because systemd says your system cannot hibernate. It then falls back to the next best thing, which is HybridSleep.

You can try something like that:
gdbus call --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 --method org.freedesktop.login1.Manager.CanHibernate

Anonymous said...

Oh, I thought, it is just the other way round:

# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used

The output is ('yes',) for "CanHibernate" and "CanHybridSleep".

Bastien Nocera said...

No idea. File a bug? :)

Anonymous said...

Here is my bug report (o: