You are not logged in.

#1 2016-02-02 16:20:15

doragasu
Member
Registered: 2012-03-03
Posts: 160

ACPID: Cannot get it to run Xorg applications

I'm trying acpid to show LXDE logout dialog (lxsession-logout or lxde-logout, both are OK) when pressing the power button. According to the wiki, you have to define some X related variables for Xorg applications to work, and a sample function for doing this is provided. I have pasted the provided function on top of the handler.sh script and call it just before invoking lxsession-logout without success. This is how my handler.sh script looks like right now (I have removed the non relevant section):

#!/bin/bash

# Function to define the X display and obtain the MIT magic cookie.
# Needed if calling X applications.
getXuser() {
    Xtty=$(</sys/class/tty/tty0/active)
    Xpid=$(pgrep -t $Xtty -f /usr/bin/X)

    Xenv+=("$(egrep -aoz 'USER=.+' /proc/$Xpid/environ)")
    Xenv+=("$(egrep -aoz 'XAUTHORITY=.+' /proc/$Xpid/environ)")
    Xenv+=("$(egrep -aoz ':[0-9](.[0-9])?' /proc/$Xpid/cmdline)")

    Xenv=(${Xenv[@]#*=})

    (( ${#Xenv[@]} )) && {
        export XUSER=${Xenv[0]} XAUTHORITY=${Xenv[1]} DISPLAY=${Xenv[2]}
        su -c "$*" "$XUSER"
    }
}

case "$1" in
    button/power)
        case "$2" in
            PBTN|PWRF)
                logger 'PowerButton pressed'
				#getXuser lxsession-logout
				getXuser lxde-logout
				#pm-suspend
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac

[...]

esac

I know that the case statement is executed because if I uncomment the pm-suspend command, the computer suspends. But lxsession-logout/lxde-logout dialogs never pop up.

Is there anything wrong?

Offline

#2 2016-02-02 16:29:23

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,421
Website

Re: ACPID: Cannot get it to run Xorg applications

Do you use a display manager?

edit: looks grepping for /usr/bin/X no longer works:

pgrep -a X
379 /usr/lib/xorg-server/Xorg -nolisten tcp :0 vt1 -auth /tmp/serverauth.BImZkKNbK7

Seriously, this stuff changes like every two weeks. Better to go with this:

https://wiki.archlinux.org/index.php/Ac … pid_socket

Last edited by Alad (2016-02-02 16:38:08)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#3 2016-02-02 19:33:20

doragasu
Member
Registered: 2012-03-03
Posts: 160

Re: ACPID: Cannot get it to run Xorg applications

Thanks for the help. As this stuff doesn't look reliable enough, I have decided using other method: I have defined an XF86PowerOff shortcut in ~/.config/openbox/lxde-rc.xml, and it's working now.

Now I'm fighting xkb, but that's other story!

Offline

Board footer

Powered by FluxBB