shutdown (physical) button

Brian J. Tarricone bjt23 at cornell.edu
Mon Jun 16 03:43:47 CEST 2008


On Sun, 15 Jun 2008 17:43:04 -0600 David Mohr wrote:

> On Sun, Jun 15, 2008 at 5:05 PM, Jean-Christophe <jc.sid at free.fr>
> wrote:
> >
> >> I succeed making the panel power button working, but I have
> >> another problem: When I press my laptop power button, that powers
> >> off the computer, with no popup, and not saving the session.
> >> So I have just to modify my /etc/acpi/powerbtn.sh to make him
> >> launch xfsm-shutdown-helper (or another command, maybe) with the
> >> right user (this script is launched as root when power button is
> >> pressed) Any idea about what could be this command?
> >>
> > Ok I found this:
> > if  ps -A | grep xfce4-session ; then
> >    /usr/bin/xfce4-session-logout
> >    exit 0
> > fi
> >
> > which I put in powerbtn.sh, but it (xf4-session-logout) has to be
> > launched as my user, not as root. How could I?
> > Regards again
> > Jean-christophe
> 
> It might not be that easy, but you could try running "
> su -c /usr/bin/xfce4-session-logout $user
> 
> where $user is your usual username
> 
> Note that this only works if you are the only user on the laptop,
> otherwise you would need to parse the output of ps to find what user
> is running xfce4-session.

That's not gonna work... for starters, you need DISPLAY set, which is
easy, but you also need SESSION_MANAGER set, but that value changes
with every new session.  You'd have to do something like run a script
on startup that saves that env var to a file somewhere, and then your
shutdown script would have to read that file and set the var.  An
exercise left to the reader ^_^.

	-brian




More information about the Xfce mailing list