Re: gnome-session: how to shutdown gnome-session from root?



On Fri, 2006-12-08 at 19:33 +0100, Stefano Sabatini wrote:
Hi Ritesh, and thanks for your reply.

On date Friday 2006-12-08 22:22:35 +0530, Ritesh Khadgaray wrote:
On Fri, 2006-12-08 at 15:43 +0100, Stefano Sabatini wrote:
Hi all,

I would like like to setup acpid to automatically launch the
gnome-session-save program when the power button is pressed (and gnome
is running).

there were talks with gnome-power-manager on this. not too sure, where
or what it was about.

try using dbus system wide service.
http://cvs.gnome.org/viewcvs/*checkout*/gnome-power-manager/docs/dbus-interface.html

python scripts are your friend.


The problem is that when I run from the power-button associated script
the command:

sudo gnome-session-save --gui --kill
this will most probably not work.
we need a functional SESSION_MANAGER value.

$ echo $SESSION_MANAGER


I get this message in a GTK error window dialog:

"Could not connect to the session manager"

SESSION_MANAGER variable as stated above.

So, SESSION_MANAGER is defined running the command in the gnome user
environment, but it's not defined in the root environment neither in
the minimal environment of the fake sds command:

SESSION_MANAGER is set by gnome-session program, afaik.

sudo -u <gnome username> gnome-session-save --gui --kill

The only possibility I see to solve this problems is:

to hack the gnome initialization procedure to do something as:
echo $SESSION_MANAGER > /tmp/gnome-session-manager
(e.g. executing it as an auto startup program)


sounds nice. try using ~/tmp ?


Then in the power-button activation script to do:
sudo -u <gnome-user> kill-gnome-session

where kill-gnome-session is something as
#! /bin/sh
$SESSION_MANAGER=$(cat /tmp/gnome-session-manager)
gnome-session-manager --gui --kill

It seems to me too complex (and not portable, you need to modify
manually the gnome-session-properties, and you need *root* permission
to write in /tmp).

So this doesn't seem at all a viable solution. Could someone point out
a simpler/better solution?

KDE solves the problem in this way (for what I can see from my
/etc/acpi/power-button script):
if ps -e -o command | grep -q '[k]desktop' && test -f /usr/bin/dcop; then
dcop --all-sessions --all-users ksmserver ksmserver logout 0 2 0 && exit 0
else ...

Is possible to use a similiar method (maybe using DBUS) with gnome?

dang ! even dbus uses DBUS_SESSION_BUS_ADDRESS for per-user session
management.

you will have to use dbus system wide service.


Cheers
--
Ritesh Khadgaray
LinuX N Stuff
Ph: +919822394463
Eat Right, Exercise, Die Anyway.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
gnome-list mailing list
gnome-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gnome-list