You are not logged in.

#1 2010-04-04 10:22:40

moere
Member
Registered: 2010-02-14
Posts: 29

[solved] lxde - lxsession-logout by pressing the power button

Hi there!

I am using lxde, I want the lxsession-logout dialog to popup when I press the powerbutton.
I followed this instruction https://wiki.archlinux.de/title/Rechner … nterfahren
( edit the /etc/acpi/handler.sh and add /sbin/halt - and this works.)

but when I add /usr/bin/lxsession-logout instead and I press the powerbutton nothing happens (while being logged in as a user and with lxde running).

so the command lxsession-logout is not executed at the righ place?! cause when I start it in a lxterminal it pops up.


Help is appreciated.


greets moere

Last edited by moere (2010-04-04 14:21:06)

Offline

#2 2010-04-04 10:46:20

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: [solved] lxde - lxsession-logout by pressing the power button

The command lxsession-logout is run in the wrong context (root, no DISPLAY env var, no access to X)
The wiki article about acpid has a nice section on how to obtain and set those variables:
http://wiki.archlinux.org/index.php/Acp … nt_display

Hope it helps :-)

Regards,

raf

Offline

#3 2010-04-04 14:20:38

moere
Member
Registered: 2010-02-14
Posts: 29

Re: [solved] lxde - lxsession-logout by pressing the power button

thank you raf_kig.


Additionally to your hint I found


http://forum.lxde.org/viewtopic.php?f=8&t=205

My /etc/acpi/handler.sh looks now like so:

 getuser ()
    {
     export DISPLAY=`echo $DISPLAY | cut -c -2`
     user=`who | grep " $DISPLAY" | awk '{print $1}' | tail -n1`
     export XAUTHORITY=/home/$user/.Xauthority
     eval $1=$user
}

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PWRF)   logger "PowerButton pressed: $2"
                        getuser "$user"
                        echo $user > /dev/tty5
                        export _LXSESSION_PID=`pidof lxsession`
                        su $user -c "lxsession-logout" ;;
 *) logger "ACPI action undefined $2" ;;
    esac
    ;;

It even works without getting the user and starting the lxsession-logout as root by getting only the lxsession pid:

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PWRF)   logger "PowerButton pressed: $2"
                        export _LXSESSION_PID=`pidof lxsession`
                        lxsession-logout ;;
 *) logger "ACPI action undefined $2" ;;
    esac
    ;;

but running the lxsession-logout as user rather than root seems to me more elegant.



greets moere

Offline

Board footer

Powered by FluxBB