GNOME Bugzilla – Bug 375682
GNOME session not saved when pressing the power button
Last modified: 2006-12-17 12:30:52 UTC
Please describe the problem: This bug was originally opened at: https://launchpad.net/distros/ubuntu/+source/gnome-power-manager/+bug/62049 On the "Power Management Preferences", when choosing "Shutdown" as the action for "When power button is pressed", the system shuts down as expected after pressing the power button. * However, the gnome session is not saved as it would have been expected [1]. On the other hand, when Quitting the system through the menus (System>Quit...>Shutdown), the session is saved as expected. [1] having "Automatically save changes to session" activated under gnome-session-preferences. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Sure this is a bug - I'm not sure if we can just read the setting for gnome-session - can you see any problems with this?
Bernat, do you want to have a go at creating a patch to fix this? I can help you as much as needed.
I'd love to, but I do not know how long it will take me. I've got only a basic knowledge of GTK2 and an even more limited knowledge of ACPI. If you could simply give me a few general directions/ideas on how to implement this, I could try to take it from there. Just a question, though: why can g-p-m not simply do what pressing the "Shut Down" button effectively does in this case? I'll start having a look at the g-p-m code this weekend.
Ohh, no ACPI, and minimal gtk work required. Have a look in gpm-manager.c and gpm-screensaver.c and see what you think.
Well, having just had a look at the gpm-manager.c code in CVS (revision 1.238), and if I understand it correctly, it seems that this has already been implemented in the gpm_manager_shutdown() function. Has this also been tested? If not, I'll try to patch my 2.16.1 .deb package sources (where, BTW, the Debian people commented out the gnome_client_request_save() call) and try it on my Edgy system.
Ok, just for test purposes I "backported" the gpm_manager_shutdown() and gpm_manager_reboot() functions from CVS to my 2.16.1-0ubuntu3 package sources. The only difference to the current CVS sources regarding this functionality, is that I read the /apps/gnome-session/options/auto_save_session directly instead of using /apps/gnome-power-manager/session_request_save. This new g-p-m gconf key was not present at the time of the 2.16 release, and since I just wanted to keep it simple, I did not bother creating it. Now the session is saved as expected. However, there are a couple of issues I've noticed: 1.- In CVS, gnome_client_request_save() is invoked as follows: gnome_client_request_save (gnome_master_client (), GNOME_SAVE_GLOBAL, FALSE, GNOME_INTERACT_NONE, FALSE, TRUE); I believe the third parameter ('shutdown') should be set to TRUE. In this way, the gnome session is shut down and the logout sound is played (when this is set to FALSE, it is not played). I've also noticed that when 'shutdown' is FALSE epiphany always chrashes. 2.- I haven't checked whether many applications are properly session-managed, but what I've seen is that gedit always fails to open the last documents of the previous session when shutting down like this. It always starts with an empty "Unsaved Document". 3.- I'm wondering, is it really necessary to read /apps/gnome-session/options/auto_save_session? Should gnome_client_request_save() not already take care of this? I mean, if auto_save_session is set, should gnome_client_request_save() itself not decide whether the session must be saved or not? Reading the documentation it is not clear to me what the expected behaviour is. I'll try to find out more in the next few days if I've got time.
Could you generate a patch against CVS to use the /apps/gnome-power-manager/session_request_save key instead of the g-p-m one please? Thanks.
Created attachment 78497 [details] [review] "Save session on shutdown" patch for the 2.16.1-0ubuntu3 g-p-m package This is a patch for the current ubuntu g-p-m package (2.16.1-0ubuntu3) (http://packages.ubuntu.com/edgy/gnome/gnome-power-manager). As I said before, I simply adapted the gnome_client_request_save() functions from CVS (gpm-manager.c 1.238, same as v1.241) to include a check for the save_session flag -which in this patch is read directly from the gnome-session gconf key- and changed the 'shutdown' parameter to TRUE.
Richard, I'm not sure I understand your question correctly: > Could you generate a patch against CVS to use the > /apps/gnome-power-manager/session_request_save key instead of the g-p-m one > please? Thanks. did you mean " */apps/gnome-session/options/auto_save_session* instead of the g-p-m one" or "/apps/gnome-power-manager/session_request_save key instead of the *g-s* one" ? In any case, I'm attaching 3 patches, hoping that they will be useful (at least for reference purposes): 1.- 56-disable-session-save-on-shutdown.patch This is a patch for the current ubuntu g-p-m package (2.16.1-0ubuntu3) (http://packages.ubuntu.com/edgy/gnome/gnome-power-manager). As I said before, I simply adapted the gnome_client_request_save() functions from CVS (gpm-manager.c 1.238, same as v1.241) to include a check for the save_session flag -which in this patch is read directly from the gnome-session gconf key- and changed the 'shutdown' parameter to TRUE. 2.- save_session_using_gpm_gconf.diff This is a patch against the current gpm-manager.c on CVS (1.241) where the only thing I've done is set the 'shutdown' parameter to TRUE in the gnome_client_request_save() calls. The check for save_session is still performed with the g-p-m gconf key. 3.- save_session_using_gs_gconf.diff This is a patch against the current gpm-manager.c on CVS (1.241) where I've set the 'shutdown' parameter to TRUE in the gnome_client_request_save() calls. The check for save_session is still performed by reading the gnome-session gconf key. Note that I still haven't had the time to investigate the issues (1, 2, 3) I was mentioning in my previous comment.
Created attachment 78498 [details] [review] "Save session on shutdown" patch against CVS using the gpm gconf key This is a patch against the current gpm-manager.c on CVS (1.241) where the only thing I've done is set the 'shutdown' parameter to TRUE in the gnome_client_request_save() calls. The check for save_session is still performed with the g-p-m gconf key.
Created attachment 78499 [details] [review] "Save session on shutdown" patch against CVS using the gnome-session gconf key This is a patch against the current gpm-manager.c on CVS (1.241) where I've set the 'shutdown' parameter to TRUE in the gnome_client_request_save() calls. The check for save_session is still performed by reading the gnome-session gconf key.
Comment on attachment 78498 [details] [review] "Save session on shutdown" patch against CVS using the gpm gconf key --- gpm-manager_1.241.c 2006-12-17 09:14:02.000000000 +0100 +++ gpm-manager_gconf-gpm.c 2006-12-17 09:24:58.000000000 +0100 @@ -644,7 +644,7 @@ if (save_session == TRUE) { gnome_client_request_save (gnome_master_client (), GNOME_SAVE_GLOBAL, - FALSE, GNOME_INTERACT_NONE, FALSE, TRUE); + TRUE, GNOME_INTERACT_NONE, FALSE, TRUE); } gpm_hal_shutdown (manager->priv->hal); ret = TRUE; @@ -682,7 +682,7 @@ if (save_session) { gnome_client_request_save (gnome_master_client (), GNOME_SAVE_GLOBAL, - FALSE, GNOME_INTERACT_NONE, FALSE, TRUE); + TRUE, GNOME_INTERACT_NONE, FALSE, TRUE); } gpm_hal_reboot (manager->priv->hal);
Sorry for the noise -and the mess. I uploaded the wrong files (sources instead of patches). I'm trying to sort this out now.
Created attachment 78500 [details] [review] "Save session on shutdown" patch against CVS using the gpm gconf key This is a patch against the current gpm-manager.c on CVS (1.241) where the only thing I've done is set the 'shutdown' parameter to TRUE in the gnome_client_request_save() calls. The check for save_session is still performed with the g-p-m gconf key.
Created attachment 78503 [details] [review] "Save session on shutdown" patch against CVS using the gnome-session gconf key This is a patch against the current gpm-manager.c on CVS (1.241) where I've set the 'shutdown' parameter to TRUE in the gnome_client_request_save() calls. The check for save_session is performed by reading the gnome-session gconf key.
2006-12-17 Richard Hughes <richard@hughsie.com> * data/gnome-power-manager.schemas.in: * src/gpm-conf.h: * src/gpm-manager.c: Don't use our own custom key for saving the session on shutdown, instead use the gnome-session "auto-save" key. Based on a patch from Bernat Tallaferro, many thanks. Fixes #375682 I've not included the gnome_client_request_save as I don't think we should be racing between a logout and a shutdown. I'll ask around and see what we should do.