GNOME Bugzilla – Bug 657201
"Suspend when closing lid" policy broken
Last modified: 2012-10-25 08:42:40 UTC
Created attachment 194532 [details] [review] patch to implement a more satisfying check Gnome-power-manager explicitly disables suspend-on-lid closed when docked, because some people close the lid on the laptop and just use an external screeen. However, those people typically have mirrored displays or, at the very least, move the activities bar to the external display. In my case (external display+keyboard+mouse, but activities bar on the laptop screen) it is pretty obvious that I want to suspend the laptop, as the activities bar is not accessible anymore when I close the lid. Even more so when there is no external display attached at all. Looking for a docking station seems to me like a cheap replacement for the desired test, which is: 1) that the user has at least one active (possibly mirrored) external display; 2) the laptop panel off, or mirrored, or at least non-primary. Perhaps you could require an external keyboard and/or mouse too, but that's the last 1% of the configurations. The attached patch implements the above condition by asking GnomeRR for display information. The patch is based on 3.1.2.
Created attachment 199998 [details] [review] patch to implement a more satisfying check redone against gnome-settings-daemon
I believe this is already implemented correctly in GNOME 3.3: http://people.gnome.org/~federico/news-2011-12.html#docking-stations Could you please double-check whether it's working now in GNOME 3.3?
Kind of. It implements a policy that probably satisfies 50% of the users, and probably will make the other 50% even more angry. Federico says: A laptop will stay running (i.e. not suspended) as long as there are monitors plugged into it, even if the lid is closed. This takes care of the "I want to close the laptop and use an external monitor" problem. The laptop will suspend when no monitors are plugged in if you close the lid. Except that some people actually do use both monitors. For them, closing the lid is something you do at the end of the day, not at the beginning; in fact it's the most sensible thing to do at the end of the day. Open in the morning, close in the evening, is more intuitive than "find the power button in the morning, hit Fn-F4 or suspend the laptop from the menu in the evening". At least to me it's so much the only sensible thing, that when I first upgraded to F15 I thought it was a kernel bug failing to detect lid close, not a GNOME3 change! So far I stayed out of all GNOME3 polemic and actually like it pretty well. But this really looks like something that needs to be customizable in the main settings center.
I'm not sure I agree with your analysis of the use case. (In reply to comment #3) <snip> > Except that some people actually do use both monitors. There's nothing precluding the user from using both monitors. > For them, closing the > lid is something you do at the end of the day, not at the beginning; in fact > it's the most sensible thing to do at the end of the day. Open in the morning, > close in the evening, is more intuitive than "find the power button in the > morning, hit Fn-F4 or suspend the laptop from the menu in the evening". You're using this machine like a desktop, with a huge mechanical switch (the lid). > At least to me it's so much the only sensible thing, that when I first upgraded > to F15 I thought it was a kernel bug failing to detect lid close, not a GNOME3 > change! The only sensible thing would be to unplug all the cables from your laptop and take it away :) In fact, turning off the monitor (thus removing the external display) and closing the laptop's lid should have the laptop suspend correctly. Then you just need to do the reverse, in any order, for the setup to be available again in the morning. > So far I stayed out of all GNOME3 polemic and actually like it pretty well. What polemic? I really don't care much for this sort of discussion especially in Bugzilla (because it sounds like "hey, some people say your stuff is crap, but I won't say that if you implement what I tell you to"). > But this really looks like something that needs to be customizable in the main > settings center. I don't think it does.
> > Except that some people actually do use both monitors. > > There's nothing precluding the user from using both monitors. Sure. But then the policies become very unintuitive. > > For them, closing the > > lid is something you do at the end of the day, not at the beginning; in fact > > it's the most sensible thing to do at the end of the day. Open in the > > morning, close in the evening, is more intuitive than "find the power button > > in the morning, hit Fn-F4 or suspend the laptop from the menu in the evening". > > You're using this machine like a desktop, Yes, I am, except when I travel. I suspect a sizable part of docking station users do that. > with a huge mechanical switch (the lid). And a battery, but we digress. > The only sensible thing would be to unplug all the cables from your laptop and > take it away :) From a home office? :) > In fact, turning off the monitor (thus removing the external display) and > closing the laptop's lid should have the laptop suspend correctly. Then you > just need to do the reverse, in any order, for the setup to be available again > in the morning. That sounds acceptable, but wouldn't it screw up all the windows that are positioned on one of the monitors? (On the first monitor that I turn off?) > > So far I stayed out of all GNOME3 polemic and actually like it pretty well. > > What polemic? I really don't care much for this sort of discussion especially > in Bugzilla (because it sounds like "hey, some people say your stuff is crap, > but I won't say that if you implement what I tell you to"). Yes, that's why I stayed out of it. But this time it cannot sound like that, does it? There's two patches attached right below, and I'd be willing to do one for the settings center as well.
(In reply to comment #5) <snip> > > In fact, turning off the monitor (thus removing the external display) and > > closing the laptop's lid should have the laptop suspend correctly. Then you > > just need to do the reverse, in any order, for the setup to be available again > > in the morning. > > That sounds acceptable, but wouldn't it screw up all the windows that are > positioned on one of the monitors? (On the first monitor that I turn off?) Probably. With luck, the window manager would act appropriately when the screen reappears (and if it doesn't it's probably worth filing a bug about). The other way would be to force suspend with the power button, close the lid. Then reopening the lid should have the appropriate behaviour, un-suspending the machine.
> > In fact, turning off the monitor (thus removing the external display) and > > closing the laptop's lid should have the laptop suspend correctly. Then you > > just need to do the reverse, in any order, for the setup to be available again > > in the morning. > > That sounds acceptable, but wouldn't it screw up all the windows that are > positioned on one of the monitors? (On the first monitor that I turn off?) > > Probably. With luck, the window manager would act appropriately when the screen > reappears (and if it doesn't it's probably worth filing a bug about). At least on GNOME 3.2, undock + redock leaves the windows all on one display. Having the windows flock to one monitor in GNOME 3.4 would probably be even worse. > The other way would be to force suspend with the power button, close the lid. > Then reopening the lid should have the appropriate behaviour, un-suspending the > machine. The power button does absolutely nothing here, even acpi_listen does not report anything when I press it (Thinkpad T500). But honestly it is not an alternative, what you're saying is just "tough luck, change your habits". I could just as well type Fn+F4 or look for the suspend menu item. But neither a 3 millimeter button, nor a key combination nor a menu item are not the same thing as an object that I can "slam" down with my hand, perhaps while I'm not sitting anymore.
We clearly have conflicting wishes: - "I don't want my laptop to suspend when I close the lid if it's in the docking station with an external monitor" - that's the behavior I implemented - "I want my laptop to suspend when I close the lid, because that's when I stop using it" - Paolo's case (Editor's note: I *do* close my laptop and leave it on my desk at the end of the day, even if I don't have a docking station, because otherwise it gets dusty really fast.) The part of gsd-power-manager.c in question right now does this: /* perform policy action */ if (non_laptop_outputs_are_all_off (manager->priv->x11_screen)) { g_debug ("lid is closed; suspending or hibernating"); do_power_action_type (manager, action_type); } else g_debug ("lid is closed; not suspending nor hibernating since some external monitor outputs are still active"); And the non_laptop_outputs_are_all_off() function is just this: static gboolean non_laptop_outputs_are_all_off (GnomeRRScreen *screen) { GnomeRRConfig *config; GnomeRROutputInfo **outputs; int i; gboolean all_off; config = gnome_rr_config_new_current (screen, NULL); /* NULL-GError */ if (!config) return FALSE; outputs = gnome_rr_config_get_outputs (config); for (i = 0; outputs[i] != NULL; i++) { if (is_laptop (screen, outputs[i])) continue; if (gnome_rr_output_info_is_active (outputs[i])) { all_off = FALSE; goto out; } } all_off = TRUE; out: g_object_unref (config); return all_off; } I.e. if any external monitors are connected and have a video mode assigned, don't suspend the laptop. Maybe we need a simple boolean setting, external-monitors-impede-suspend, defaulting to true as per the current behavior. People with Paolo's case can set it to false. One of the "main" things of my patches for docking stations was to remove the "if (is_docked()) ..." part, since I thought we could resolve everything based on the presence of active external monitors, regardless of docking status. I'm not sure if this needs to be considered again. Paolo, would you have time to implement that boolean key? (Bastien: your "In fact, turning off the monitor (thus removing the external display)" from comment #4 doesn't quite work - RANDR reports "connected" for monitors that are physically connected, even if they are turned off. At least it does for my VGA monitors. You have to unplug them from the computer for RANDR to notice.)
> Maybe we need a simple boolean setting, external-monitors-impede-suspend, > defaulting to true as per the current behavior. People with Paolo's case can > set it to false. Yay! :) Or "suspend-on-closed-lid". The GUI would be "On closed lid:" with choices "always suspend" and "use external display". I'll leave that to the designers. BTW, do your patches move the primary display (and activities bar) to the external monitor? > One of the "main" things of my patches for docking stations was to remove the > "if (is_docked()) ..." part, since I thought we could resolve everything based > on the presence of active external monitors, regardless of docking status. I'm > not sure if this needs to be considered again. I think it's fine to leave it as you did. > Paolo, would you have time to implement that boolean key? Sure, anything to get it integrated. :) Please tell me whether I should also patch settings center or gnome-tweak-tool.
*** Bug 671799 has been marked as a duplicate of this bug. ***
*** Bug 575559 has been marked as a duplicate of this bug. ***
(In reply to comment #9) > Yay! :) Or "suspend-on-closed-lid". The GUI would be "On closed lid:" with > choices "always suspend" and "use external display". I'll leave that to the > designers. Sorry for the late reply. I did a little research: * Windows offers a "what to do when the lid is closed" option, both for "on AC power" and "on battery". It has three possibilities for each - do nothing, shut down, or suspend/hibernate. http://windows.microsoft.com/en-US/windows-vista/Change-what-happens-when-you-close-your-mobile-PC-lid http://windows.microsoft.com/en-US/windows7/Change-what-happens-when-you-close-your-laptop - same as the previous one, but requires Silverlight http://www.sevenforums.com/attachments/customization/137765d1297381581-choose-what-closing-lid-does-screenhunter_01-feb.-10-17.38.gif * MacOS doesn't provide any options; it always suspends when you close the lid. Third-party software can be used to change this. http://forum.notebookreview.com/apple-mac-os-x/515312-how-choose-what-closing-lid-does.html http://semaja2.net/insomniaxinfo (this is the software in question) Right now g-s-d's power plugin already has these configuration keys: org.gnome.settings-daemon.plugins.power.lid-close-ac-action org.gnome.settings-daemon.plugins.power.lid-close-battery-action They both default to "suspend", and both can take these values: blank suspend shutdown hibernate interactive nothing Having all of those in the GUI is overkill. Maybe we can just expose "suspend" and "nothing". Exposing "shutdown" as Windows does sounds dangerous; AFAICT this will cause apps to terminate even with unsaved data. Paolo, do you want to work on that? > BTW, do your patches move the primary display (and activities bar) to the > external monitor? Not by themselves, but the current code in the xrandr plugin makes that happen. We always need a primary display somewhere, for the activities bar - if there's only an external monitor available (e.g. lid is closed), we use it. When the laptop opens, we give preference to its built-in display again (it's slightly more complicated than that, but in general it does the right thing).
> Having all of those in the GUI is overkill. Maybe we can just expose "suspend" > and "nothing". Exposing "shutdown" as Windows does sounds dangerous; AFAICT > this will cause apps to terminate even with unsaved data. > > Paolo, do you want to work on that? They are already in gnome-tweak-tool, the only necessary thing is the new boolean. For now I'll add it to g-t-t as well. I should be able to do this before Easter, I already upgraded my GNOME to 3.3.9x which was the main blocker for the work.
(In reply to comment #12) <snip> > Having all of those in the GUI is overkill. Maybe we can just expose "suspend" > and "nothing". Exposing "shutdown" as Windows does sounds dangerous; AFAICT > this will cause apps to terminate even with unsaved data. > > Paolo, do you want to work on that? I don't think we want to change the design. And if we did, we would need to define the design before coming up with work-arounds for it.
Created attachment 213212 [details] [review] patch to add lid-close-check-monitors setting This adds a new setting for people who like to use at the same time the laptop screen and an external monitor, effectively using the laptop as a workstation most of the time. In such an environment, shutting down the lid is the obvious way to end a work session; checks on external monitors get in the way.
Created attachment 213213 [details] [review] gnome-tweak-tool patch to add the setting
>> Having all of those in the GUI is overkill. Maybe we can just expose "suspend" >> and "nothing". Exposing "shutdown" as Windows does sounds dangerous; AFAICT >> this will cause apps to terminate even with unsaved data. This is because gnome-tweak-tool is just a thin veneer over gsettings. Definitely the GUI would be polished if some of these settings were to migrate to gnome-settings-center, but I don't think it is necessary for the lid close action settings. The new GnomeRR-based policy actually works really well, and migrating my new setting to gnome-settings-center should be enough. In other words, "let the user choose choose whether to keep working on external monitors" after shutting down the lid, and otherwise always suspend on both battery and AC similar to Mac OS X (comment 12). The setting could be hidden if not on a laptop.
Thanks for the patches, Paolo - I'll review them ASAP.
This is good, Paolo, thanks! I think I'll change the name of the configuration key to something a bit more explanatory - but I don't have a good name yet. I'm wondering how to best expose this in the Power panel in the control center. Right now we have On battery power When plugged in Suspend when inactive for [30 minutes v] [Don't suspend v] When power is critically low [Hibernate v] [Battery indicator] Having this in addition: [x] External monitors let the laptop operate even with a closed lid would be *terrible* wording :) Any ideas?
What about the text I used in the gsettings XML, "Work on an external monitor after closing lid"? (My first version had the reverse meaning for true/false, but then I couldn't find a decent wording even for gnome-tweak-tool's standards...).
(In reply to comment #19) > This is good, Paolo, thanks! > > I think I'll change the name of the configuration key to something a bit more > explanatory - but I don't have a good name yet. > > I'm wondering how to best expose this in the Power panel in the control center. > Right now we have > > On battery power When plugged in > Suspend when inactive for [30 minutes v] [Don't suspend v] > When power is critically low [Hibernate v] > > [Battery indicator] > > Having this in addition: > > [x] External monitors let the laptop operate even with a closed lid > > would be *terrible* wording :) Any ideas? UI changes are out of the scope of this bug, FWIW. File a separate bug about it and get in touch with the designers.
Created attachment 214194 [details] [review] bgo657201-lid-close-suspend-with-external-monitor.diff I've pushed this patch to the docking-stations branch as commit f10c8922. It's basically your patch, but with a key name of "lid-close-suspend-with-external-monitor" defaulting to False, to preserve the current behavior for docking stations. Thanks again for the patch, Paolo, and I hope you don't mind changing your patch for gnome-tweak-tool :) I'll merge this to master after I do some more changes. When we *don't* suspend because there are external monitors still present, we can run into this situation: 1. External monitor is present. 2. You close the lid - laptop doesn't suspend. 3. You unplug the external monitor - g-s-d doesn't notice, since VGA unplugs aren't detected (just plugging in). 4. You put your laptop in your backpack and it melts. So in the case where we don't suspend, we need a little timer so that we can check the state of the monitors after a couple of minutes after the lid got closed.
One nit: However, when an external monitor is plugged in to the laptop, closing the lid will not suspend the machine so that one can keep working on that monitor (e.g. for docking stations or media viewers). Set this key to False to take this action, or to True... sounds a bit weird (you say it does X and then say it can be changed). Perhaps: By default, however, closing the lid will not suspend the machine so that one can keep working on that monitor (e.g. for docking stations or media viewers). Set this key to False to keep the default behavior, or to True...
Created attachment 214197 [details] [review] updated gnome-tweak-tool patch for the new settings name
Created attachment 214198 [details] [review] updated gnome-tweak-tool patch for the new settings name
Thanks for the text - pushed and merged to master. I'll do the timer fixes on the branch and merge them later.
(In reply to comment #26) > Thanks for the text - pushed and merged to master. I'll do the timer fixes on > the branch and merge them later. Could you please make an effort to follow the commit message style next time?
Bleh, sorry, I didn't think of checking previous commit messages. Maybe we should have a HACKING file there.
Now that suspend is not anymore in the user menu, is there any chance this setting could graduate to gnome-control-center? (Previously, I could log out and shutdown without knowing Alt or gnome-tweak-tool; but now I cannot anymore suspend without knowing one of them).
*** Bug 676455 has been marked as a duplicate of this bug. ***
*** Bug 684266 has been marked as a duplicate of this bug. ***
This became hardly usable in 3.6.1 due to the laptop-lid behavior hinted to in comments 5-8, which is now implemented in gsd-xrandr. All windows are smashed in one screen before the laptop has the occasion to suspend. Patch will come tomorrow.
Created attachment 227228 [details] [review] patch to make follow-lid optional in gsd-xrandr + simplify gsd-power config
(In reply to comment #32) > This became hardly usable in 3.6.1 due to the laptop-lid behavior hinted to in > comments 5-8, which is now implemented in gsd-xrandr. All windows are smashed > in one screen before the laptop has the occasion to suspend. > > Patch will come tomorrow. File a new bug.
Created attachment 227231 [details] [review] matching gnome-tweak-tool patch