UBUNTU: XOpenDisplay(NULL) fails when program run in boot sequence via rc.local

房东的猫 提交于 2019-11-29 15:54:16
David

Solved thanks to tripleee.

Ubuntu now uses LightDM and so by adding the line below to /etc/lightdm/lightdm.conf

greeter-setup-script=usr/bin/'my-script'

where 'my-script' is:

#!/bin/sh
/usr/bin/'my-prog' &

everything works.

Your program should only start once X11 is up and running. But a much better design is to make a service which runs with root privileges, but doesn't use X, and arrange for an X client to talk to it somehow. If you cannot exist without X, hook into the X11 startup sequence, rather than the system startup.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!