从 Linux 中的 acpi 事件执行 PyQt 应用程序
我想使用 PyQt 应用程序在 Linux 下触发某些 acpi 事件时显示图像。
我已经设置了事件的配置,并且当事件被触发时执行 python 脚本,但是当程序到达 QApplication 的创建时,
app = QApplication(sys.argv)
它会停止而不会出现错误。 我尝试设置与当前用户相同的 DISPLAY 和 PATH 环境变量,但它不起作用。
这是我的事件文件:
event=sony/hotkey SNC 00000001 00000011
action=/etc/acpi/vaio-tools/brightness/sonybright.sh up 2>&1>/tmp/vaio-tools_brightness.log
我试图在 /tmp/vaio-tools_brightness.log 中找到一些错误,但在代码中到达 QApp 创建后它不会记录任何内容。
有什么提示吗?
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序由 root 运行,而 root 无权访问用户的 X 显示。
将 $XAUTHORITY 设置为用户使用的 X 权限文件的路径,或者使用类似以下内容(未经测试):
有关更多信息,请参阅 xauth 和 Xsecurity 的手册页这。
更好的解决方案是让 ACPI 事件通过 DBus 发送消息,并在侦听该消息的用户会话中运行应用程序。
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):
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.