LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 05-10-2011, 09:32 AM   #1
MonkeyKnight
LQ Newbie
 
Registered: May 2011
Posts: 3

Rep: Reputation: 0
Question Using SDL with minimal X components


This may be more of a linux general question, but the distro that we will be performing this on is Debian, with a minimal install.


High level scenario: We have some small x86 based motherboard and are deploying a kiosk system in a dedicated enclosure, booting off of a USB stick. When they go to production, there is no need to load anything but our program. We have custom hardware for visitors to interact with the kiosk system, so we are not even hooking up a keyboard much less a mouse to the system.


Here is the goal: To run a C++ compiled program that uses SDL (http://www.libsdl.org/) to display a game, without having to load a desktop or any other unnecessary X components.


Here is the current setup: Running Puppy linux from a USB stick, starting our app in the .xinitrc script. Making sure our app takes up 100% of the screen, hiding the mouse cursor.


So whats the problem? I would like to be loading only the most minimal components that we have to, to run our program. As our kiosk system gets bigger and demands more cpu/gpu/ram I would like to know that we are not waisting any resources running a desktop system in the background. The tiny motherboard is x86, but we are running with 512Mb of ram and the cpu is equally small (can't remember numbers off the top of my head although I want to say 1.xGhz intel)

Another issue that I see with the current system, is that if our program isn't running you can see a desktop in the background. We do have all icons off the desktop, but there is still evidence of a full blown desktop system running. And by a Linux fella, easily identifiable as Puppy.

I would like to know that if our application did not start (or dare I say crash! AAahhhh!) that it would either a) Will fall back to a shell. b) Display only a very minimal desktop that only has our company logo as the background, or maybe a message saying to reboot or something. Maybe some kiosk branding, who knows.


Ultimately whats the question? On a net install or any other minimal headless install, what would be the best way of achieving my intended goal? I would need to install X11, but I don't think that I will be needing a window manager or a desktop. And how would I (utilizing common practice methods) only start X when I needed it? Is it possible to start X from within my program? And if my program elegantly crashes, I can kill X? That way if I was at the CLI, I could just run the command "kiosk" and it would fire up?


I have been using Linux for almost a decade, but have never had to play with X like this. All my development has been on decapitated servers up to this point. Thanks for any help, and I apologize if this is somewhere already. I have googled it, and can't seem to find anything quite like this.
 
Old 05-10-2011, 06:58 PM   #2
plpl303a
Member
 
Registered: May 2011
Posts: 52

Rep: Reputation: 3
Quote:
Originally Posted by MonkeyKnight View Post
I would like to know that if our application did not start (or dare I say crash! AAahhhh!) that it would either a) Will fall back to a shell. b) Display only a very minimal desktop that only has our company logo as the background, or maybe a message saying to reboot or something. Maybe some kiosk branding, who knows.
Supposing that you are running the program under an account named 'user':

Create a file /home/user/.xinitrc
The file should be mode 700 and have:

#!/bin/sh
exec my_kiosk_program


When the kiosk program exits, so will X. Or you could get more fancy and do something like:

#!/bin/sh
while [ 1 ]
do
my_kiosk_program
done


And then if the program crashes, it will be re-executed immediately.

Or you could play tricks with /etc/inittab to spawn the program (and X) at startup automatically.


Quote:
And how would I (utilizing common practice methods) only start X when I needed it? Is it possible to start X from within my program?
Is there a reason you don't want X running all the time? A command prompt might look a little strange to people walking by...

I suppose your program could check if X was running and if not do a system() or fork/exec() to run X. But that seems kind of hacky...
 
1 members found this post helpful.
Old 05-10-2011, 10:57 PM   #3
MonkeyKnight
LQ Newbie
 
Registered: May 2011
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by plpl303a View Post
#!/bin/sh
while [ 1 ]
do
my_kiosk_program
done
This is how we are doing it at the moment. Great minds must think alike

Quote:
Originally Posted by plpl303a View Post
Is there a reason you don't want X running all the time? A command prompt might look a little strange to people walking by...
Good point. I confuse enough people without exposing my shells!

What is the most minimal X install to run SDL? I don't need a window manager, correct?

Quote:
Originally Posted by plpl303a View Post
I suppose your program could check if X was running and if not do a system() or fork/exec() to run X. But that seems kind of hacky...
hacky = not so good.
 
Old 05-11-2011, 01:43 AM   #4
plpl303a
Member
 
Registered: May 2011
Posts: 52

Rep: Reputation: 3
If there are no overlapping windows, a window manager should be unnecessary. Assuming your screen is 1024x768, you could maybe do something like this:


SDL_putenv("SDL_VIDEO_WINDOW_POS=0,0");
win = SDL_SetVideoMode(1024,768,...);

That will create the window with its upper left corner at 0,0 and with a size of 1024x768. Since there is no window manager, there won't be any border or title bar to take up space.
 
1 members found this post helpful.
Old 05-11-2011, 01:00 PM   #5
MonkeyKnight
LQ Newbie
 
Registered: May 2011
Posts: 3

Original Poster
Rep: Reputation: 0
Perfect. So this is all do-able. I am on the road, so this will have to wait to be implemented.

With the help of you, this cleared up a lot for me.


Thank you for all the help!
 
  


Reply



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
SDL is installed, included and linked, but will not compile SDL code mansizerooster Programming 10 05-31-2006 04:18 AM
Sourcecompiling Problem...The sdl-config script installed by SDL could not be found. deepclutch Debian 1 12-15-2005 12:15 PM
What are the X server Components? Neda Linux - Newbie 2 06-14-2005 10:37 PM
What are the X server Components? Neda Linux - General 1 06-14-2005 07:09 AM
Trying to program an SDL application but cannot find the SDL.h file:SuSE 9.2&KDevelop pujolasdf Linux - Newbie 4 03-13-2005 07:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 08:33 PM.

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