views:

30

answers:

1

Hi,

I want to use a PyQt application to display an image when some acpi event is triggered under linux.

I already setting up the configuration for the event and the python scrip is executed when the event is triggered, but when program reach the creation of the QApplication

app = QApplication(sys.argv)

it stops without error. I tried setting up the same DISPLAY and PATH environment variables as my current user but it doesn't work.

This is my event file:

event=sony/hotkey SNC 00000001 00000011
action=/etc/acpi/vaio-tools/brightness/sonybright.sh up 2>&1>/tmp/vaio-tools_brightness.log

I tried to find some error in the /tmp/vaio-tools_brightness.log but it doesn't log anything after it reach the QApp creation in code.

any hints??

A: 

Your application is run by root who doesn't have access to your users's X display.

Either set $XAUTHORITY to the path of the X authority file used by your user or use something like this (untested):

su your_user -l -c "xauth extract - $DISPLAY" | xauth merge -

See the man pages for xauth and Xsecurity for more about this.

A better solution would be to have the ACPI event to send a message via DBus and run your application in the user's session listening to that message.

Florian Diesch
Thanks, I found this page (http://www.thinkwiki.org/wiki/How_to_configure_acpid) for acpid configuration and there is the solution: to add the localhost:root using xhost and exporting the DISPLAY variable. But I'll look for your suggestion about using DBus
alfredozn