After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 375682 - GNOME session not saved when pressing the power button
GNOME session not saved when pressing the power button
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: general
2.16.x
Other All
: Normal minor
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2006-11-15 20:20 UTC by David Planella
Modified: 2006-12-17 12:30 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
"Save session on shutdown" patch for the 2.16.1-0ubuntu3 g-p-m package (2.12 KB, patch)
2006-12-17 08:53 UTC, David Planella
none Details | Review
"Save session on shutdown" patch against CVS using the gpm gconf key (59.05 KB, patch)
2006-12-17 09:04 UTC, David Planella
none Details | Review
"Save session on shutdown" patch against CVS using the gnome-session gconf key (59.15 KB, patch)
2006-12-17 09:05 UTC, David Planella
none Details | Review
"Save session on shutdown" patch against CVS using the gpm gconf key (690 bytes, patch)
2006-12-17 09:12 UTC, David Planella
none Details | Review
"Save session on shutdown" patch against CVS using the gnome-session gconf key (1.37 KB, patch)
2006-12-17 09:14 UTC, David Planella
none Details | Review

Description David Planella 2006-11-15 20:20:18 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:
Comment 1 Richard Hughes 2006-11-17 00:30:28 UTC
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?
Comment 2 Richard Hughes 2006-11-24 21:49:10 UTC
Bernat, do you want to have a go at creating a patch to fix this? I can help you as much as needed.
Comment 3 David Planella 2006-11-25 11:34:22 UTC
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.
Comment 4 Richard Hughes 2006-11-26 22:51:45 UTC
Ohh, no ACPI, and minimal gtk work required. Have a look in gpm-manager.c and gpm-screensaver.c and see what you think.
Comment 5 David Planella 2006-11-27 23:16:10 UTC
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.
Comment 6 David Planella 2006-11-28 21:49:30 UTC
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.
Comment 7 Richard Hughes 2006-12-16 14:42:33 UTC
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.
Comment 8 David Planella 2006-12-17 08:53:29 UTC
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.
Comment 9 David Planella 2006-12-17 08:54:09 UTC
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.
Comment 10 David Planella 2006-12-17 09:04:19 UTC
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.
Comment 11 David Planella 2006-12-17 09:05:27 UTC
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 12 David Planella 2006-12-17 09:08:16 UTC
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);
Comment 13 David Planella 2006-12-17 09:10:50 UTC
Sorry for the noise -and the mess.

I uploaded the wrong files (sources instead of patches). I'm trying to sort this out now.
Comment 14 David Planella 2006-12-17 09:12:02 UTC
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.
Comment 15 David Planella 2006-12-17 09:14:01 UTC
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.
Comment 16 Richard Hughes 2006-12-17 12:30:52 UTC
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.