[SOLVED] Connecting to X display in a startup script
Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm running Ubuntu 10.04, rootstock filesys, on a Marvell ARM CPU. I am trying to start a Gtk application at system boot time. I created /etc/rc2.d/S50app and made it executable, and it contains:
/home/ubuntu/test.sh &
On startup startx runs normally, and my_program executes it's non-X components, but when it tries to write to the Xserver it fails with a
"cannot open display: :0.0" message.
Changing test.sh to run a normal video player instead of my_program gives a similar result. The audio track plays, but the video player gives me errors:
VIDEO: MPEG1 384x288 (aspect 1) 25.000 fps 0.0 kbps ( 0.0 kbyte/s)
No protocol specified
vo: couldn't open the X11 display (:0.0)!
Error opening/initializing the selected video_out (-vo) device.
All this works as expected if I don't do anything in /etc/rc2.d, and instead log in as a user and run test.sh.
How can I make my program or a video player connect to the X display, when everything is started from a rcN.d script?
Well, this sounds to me like an issue I encountered a while back when I was trying to use the xdm display for a framebuffer for a server-side application...
Now, first, I would ask: When the Xserver starts, and you log into the box from a console, can you run the following without error?
Code:
~ # DISPLAY=:0 xclock
If you don't have xclock on the system, just use any simple graphical app... xeyes or gedit will do just fine. Notice that I'm simplifying which DISPLAY you are trying to access. We want to pass it to the first Xserver and not a specific screen. Let's see if that will help.
If you run the app and get the same "cannot open display" message, then let's try the following and see what happens.
From the console, type the following:
Code:
xhost +localhost
Now try to run the "DISPLAY=:0 <app>" command again and see if it goes.
ShadowCat8 - may app runs under those conditions, it's only when I try to run it all from startup that the app fails to connect to the X server. Starting X from rc2.d, and then logging in and from my tty running DISPLAY=:0 <my_app> worked. Sort of obviates the need for xhost +localhost, but even so that didn't fix things. The problem is centered around running both X, and the app, from a startup script.
dumacx - interesting idea. It worked. Now I need to try to understand what is going on. I should also try to figure out more about the difference between xinit and startx.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.