Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This 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.


  Search this Thread
Old 02-16-2012, 05:39 PM   #1
LQ Newbie
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
Connecting to X display in a startup script

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/ & contains:
sleep 8
startx &
sleep 8
export DISPLAY=:0.0

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 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

How can I make my program or a video player connect to the X display, when everything is started from a rcN.d script?
Old 02-16-2012, 06:40 PM   #2
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 258

Rep: Reputation: 52

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?
 ~ # 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:
     xhost +localhost
  • Now try to run the "DISPLAY=:0 <app>" command again and see if it goes.

HTH. Let us know.
1 members found this post helpful.
Old 02-17-2012, 05:43 AM   #3
LQ Newbie
Registered: Feb 2012
Posts: 1

Rep: Reputation: Disabled
try this, in the rcX:

/bin/xinit /etc/xinit-app -- :0.0

and in the /etc/xinit-app:
1 members found this post helpful.
Old 02-17-2012, 02:49 PM   #4
LQ Newbie
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled

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.

Thanks both.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to an unknown X display/server prushik Linux - Software 3 05-25-2009 12:04 AM
No DISPLAY variable when connecting via SSH ciphyre Linux - General 3 09-12-2008 02:36 PM
Wireless network not connecting during startup sudarshan22 Ubuntu 5 06-21-2008 10:30 AM
Connecting to a wireless access point automatically on startup timelord726 SUSE / openSUSE 2 09-30-2005 07:52 PM
Problems connecting to network on startup dairic Linux - Newbie 2 10-17-2004 02:07 PM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration