Friday 1 February 2013

Power management in GNOME 3.8

In the past couple of weeks, apart from reviewing very many patches for gnome-control-center (especially for new and re-designed panels), I've been working on updating the power management handling in GNOME.

Test suite

The first change is that we have a test suite (currently with 15 separate tests) to test interaction between gnome-settings-daemon's power management and various session and system components. This is thanks to Martin Pitt, and his work on python-dbusmock.

We'll try and add new tests as bug reports come in to avoid regressions, although some cases will remain untested because of limitations in our logging.

 All clear

Screensaver and backlight interaction

With gnome-shell becoming the sole screensaver (after the removal of fallback mode, and the obsoletion of gnome-screensaver), we've been able to streamline the code handling the various screen backlight power levels.

Your screen will now turn off as soon as the screensaver kicks in, moving your mouse in the screensaver will turn it back on for 20 seconds before turning off again, and when to dim (if you've chosen so) is dependent on whether you're on battery or not, and the default idle time (eg. if your screen turns off after 5 minutes of inactivity, the screen will dim after 4). This makes the behaviour more consistent, and predictable, compared to the mish-mash of settings we had before, where some delays were available for change in the UI, and others only through GSettings or gnome-tweak-tool.

Those constants are separate from the code, and exported to the test suite so they are flexible and can be changed if the behaviour doesn't exactly match what users are expecting.

The other change relating to that, is that the screen shield will now always pop down when the screensaver kicks in (thanks to Giovanni for the gnome-shell work). This doesn't mean that you'll have to enter your password each time, but only after the "lock delay" if you've set one.

We've also added a number of nice touches, like the screen turning back on for a short period when you plug or unplug your laptop, made sure that your laptop screen gets turned off and your session locked when closing the lid and turn off the backlight for machines where suspend causes the backlight to come back on temporarily (as seen on MacBooks).

Very very idle

We've also added a long-requested feature: the ability to force logout after a period of idle. This is useful in kiosk and computer lab situations, and is only available through GSettings. As we've added support for this feature (warning prior to logging out, with the screen turning on for a couple of seconds when the warning shows up), we've realised that the infrastructure is the same for automatic suspend/hibernate situation. This means I expect to change the default "long idle" behaviour to suspending. This will still be changeable in the Power preferences. This should land after 3.7.5, and don't worry, we'll make this change very visible in the release notes :)

*I* am not suspending by default

Inhibit

But you don't want to suspend, you really don't.

GNOME supports the draft FreeDesktop "Idle inhibition" specification, as implemented by KDE, which hopefully means that more third-party applications should start behaving better when playing back films, in presentation mode, or for large overnight downloads. This should hopefully get out of draft status before the GNOME 3.8 release.

We also have a gnome-session-inhibit tool available in gnome-session for your scripting needs.

Colophon
 
All the changes mentioned should be available in GNOME 3.7.5, and I will be available to take complaints at FOSDEM this week-end.

17 comments:

Anonymous said...

The other change relating to that, is that the screen shield will now always pop down when the screensaver kicks in (thanks to Giovanni for the gnome-shell work). This doesn't mean that you'll have to enter your password each time, but only after the "lock delay" if you've set one.

Does this mean I'll have to raise the shield every time I don't use GNOME for a few minutes, instead of just wiggling the mouse? That would be quite inconvenient.

Also, does this mean there would be a large uncertainty whether my station is locked or not? If I see a shield slide down, I assume "it's locked, I can go away". IIUIC now I'll have to raise the shield to see whether it's locked already, and lock it manually if it isn't.

Scenario:
1. Bob goes for a coffee
2. The screen dims and shield goes down
3. Bob returns and realizes "oh damn, I forgot to lock my computer!"
4. Bob wiggles his mouse and sees the shield
5. "oh good, it automatically locked itself, great"
6. Bob packs his things and leaves
7. Eve, the attacker, comes to the computer, raises the shield and finds the session unlocked (the lock delay was still not exceeded). "This GNOME's confusing behavior is great, now I have full access to the system"

All this problems would go away if the shield automatically raised on mouse move/key press. But that wouldn't be so eye candy and awesomely cool I guess.

The other solution is the present behavior where "shield == locked computer" and people can rely on it. I don't understand what the purpose is of showing a shield without locking the computer. It's just one extra screen that doesn't have to be there and blocks your view.

JanBirsa said...

kparal makes a valid point.

Unknown said...

'this means I expect to change the default "long idle" behaviour to suspending.'

That makes no sense (see my comment in the bug).

At the same to you disable it on your own system. So why do you want to turn it on by default? I'd rather have this as opt in rather then opt out.

Jonh Wendell said...

heh, using pt_BR? :)

Tomasz said...

What's the proper way to not lose open network connections now? Is

$ systemd-inhibit --what=idle ssh somehost

enough?

Bastien Nocera said...

kparal: There should be differentiation between locked and not (the padlock at the top-left of the screen at least), and locking the screen should be possible from the shield should be possible as well.

The shield doesn't block your view, it's there when the screensaver was already on, which means the screen would have been blank.

Unknown (aka drago): I don't disable it on my own system, I usually only change the background and the terminal's colours on my systems. The italics can be used for quotes, so it was supposed to be one (see also the beginning of the last paragraph). Opt-out rather than opt-in because the majority of laptops can suspend correctly.

John: Yeah, and I forgot to switch the language to take those screenshots, silly me ;)

zdzichuBG: or "gnome-session-inhibit --inhibit suspend ssh somehost". This won't block the lid action though, so you'll need to either run systemd-inhibit for that ("systemd-inhibit --mode=block --what handle-lid-close:suspend ssh..." if it's the lid action you're trying to stop, or use office-runner if it's for a short period of time you're trying to keep your connections alive.

Anonymous said...

Nice post Bastien, in my humble opinion well explained and detailed.

Regarding to the quotation, it didn't cross my mind you were quoting somebody else, I thought you wanted to emphasize that it was your own configuration and somebody else could have something different.

Maybe using quotation marks would have been clearer (beside the emphasis). Not a big deal, though.

Dylan McCall said...

Looks great, Bastien! I've been hoping someone would clean this stuff up :) I look forward to using it.

Anonymous said...

Bastien: Yes, I understand it's a replacement for the screensaver, but contrary to the shield:
1. the screensaver could have been quickly cancelled by mouse move/key press
2. the screensaver could have been disabled completely. That was my approach.

Ikem said...

What I like to have is an idle daemon.

This is a daemon that run tasks on idle.

Tasks like:

- file synchronization
- file conversion (to save space)
- deleting temporary files
- defragmenting
- ...

Jack said...

"Your screen will now turn off as soon as the screensaver kicks in, moving your mouse in the screensaver will turn it back on for 20 seconds before turning off again"

I must say that I hate this functionality. I often have my computer sit idle while Im working at my desk and watch for notifications. I previously (3.6) had the blank/lock set to 60 minutes and would lock the machine manually if I had to step away, but with the new 'notifications on the lock screen' functionality, I was hoping I wouldn't have to deal with this problem.

Now that my monitors turn OFF when the screen shield is activated, it means i have to either extend the idle time (meaning it could remain unlocked if i step away from my machine), or constantly keep the machine active so i dont miss notifications.

Is there not a way to enable the lock shield after 10 minutes and blank screen after 30?

Unknown said...

Where is the point of having a beautiful and useful lock screen like that when the screen turns off as soon as it kicks in? I really, really hate this "improvement".

Unknown said...

I can't get it. It seems really like a bug.
1. Manually lock screen
2. Screen shield (which I like) will blink for a moment
3. Screen turns off

And no way to change that. Simply this is wrong.

Unknown said...

hi bastien,
have a small problem with this feature - it does not seem to work as advertised...
looked at the plugin code you attached, and here is how it works out for me:
1) there is no dimming of screen (functionality that I used all the time previously), screen does not dim regardless of the settings in gnome, now that the idle-dim-time key is gone user can not control it any more by gsettings
2) if blank screen is set to 'never' dim does not take place after 60sec, screen is on default brightness all the time
3) if blank screen is set to some value the 4.0/5.0 ratio is not used to dim the screen - it is just blanked after specified time

I'm using fedora - all of this functionality was there until F19, which included new gnome release. It looks like others are fixing the problem by adding patches >> ubuntu: ubuntu-gnome-default-settings to override idle-dim-time

Am I missing sth or it is as it should be???

Bastien Nocera said...

szkubar: Best file that in bugzilla...

Unknown said...

OK - will do
btw, did you managed to get proper behavior (i.e. dimming then blanking) on your setup (I believe fedora as well)???
I already tested it on 3 machines (new installs and upgrade) and could not get it working on any of them :((
cheers

Russell Haley said...

Your screen will now turn off as soon as the screensaver kicks in

That's all well and good for laptops, but from a sample of 3 screens, one of them takes ~2 seconds to turn on, one takes 4 seconds, and the slowest takes 9. The one that takes 4 seconds is a CRT, and if it stays off for more than a few minutes, the picture appears washed out for a whole minute or so after it turns on.

Turning screens on is not always a free action, so Gnome should give the user a configurable delay between activating the screensaver and turning off monitors with DPMS.