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



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).
> > 
> > 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:
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)

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?

Cheers
-- 
Stefano Sabatini
Linux user number 337176 (see http://li.count.org)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]