I have had lots of trouble with running a pygame application such as the pre-installed wormy.py (or any application like lxterminal or minecraft-pi) on a Pi from the command-line. This means without entering the Raspbian desktop.

I have tried all the proposed solutions in the (inevitable) linked questions list:

  • From: Running X11 without Window Manager?
    • The screen turns black for a millisecond but immediately returns to the terminal again with a "server terminated successfully" and a "x server connection lost".
  • From: How can I start X11 only for a single application?
    • This is the same as above (pretty much a duplicate but more specific to Chrome). The .xinitrc doesn't appear to have any effect at all.
  • From: Run GUI app from command line
    • This had no effect. Nothing happened at all when running any app.
  • From: Run a GUI without the desktop
    • I did exactly as the accepted answer says from a fresh Raspbian installation but no dice. Also, that ctrl-alt-backspace trick to kill the GUI didn't work to kill the main Raspbian GUI - maybe I misunderstood or missed something?
  • From: Pygame from command line vs GUI
    • This looked promising until I failed to produce the same results and also got confused with the instructions.
  • From: How to set up "kiosk" mode in Raspbian?
    • Although I eventually want to boot directly to a GUI app from startup (without using the desktop!), I want to be able to run a command from the command-line at first, for testing purposes.

Is there any resource that provides a simple-to-follow step-by-step guaranteed-to-work(!) set of instructions on how I can run a GUI application from the command-line without the window manager (i.e. just X)?

Contents of the .xinitrc:


# /etc/X11/xinit/xinitrc
# global xinitrc file, used by all X sessions started by xinit (startx)

# invoke global X session script
. /etc/X11/Xsession
exec /usr/share/raspi-ui-overrides/applications/minecraft-pi
  • There is big a difference between starting something stand-alone inside X and starting a stand-alone graphical application outside X (i.e., on the framebuffer). I believe pygame, which depends on SDL, used to support a mode for the latter but no longer does, so you might as well ignore anything that involves using it without an X server.
    – goldilocks
    Jun 26, 2016 at 15:11
  • Yeah, and I've also heard using the framebuffer only for Pygame produces comparatively terrible performance. Hence my request was for with X. :) Jun 26, 2016 at 16:08
  • Note that you did not explain some of the details about of what did not work for you, which may disincline some people (e.g., me, no offence) from bothering with a question which seems to read, "I've tried everything, please suggest more....". You may also want to put 2 and 2 together with this: raspberrypi.stackexchange.com/questions/40493/… to try and debug the issue with all the conventional methods which mysteriously work for other people in other cases but not you in this case.
    – goldilocks
    Jun 26, 2016 at 16:23

1 Answer 1


I believe the first plan suggested will work, but your .xinitrc needs to be setup correctly. When you start an x server, it will go through your .xinitrc file until completion. Once it completes, the x server closes. Normally, when you start a window manager in your .xinitrc, the window manager stays open and the x server does not close. It is likely that you either aren't even starting the pygame (as in there is no "exec "), or the pygame is running to completion allowing the x server to terminate. Perhaps you have an & at the end of the exec line? That would be causing the results you have.

If you want me to assist further, please paste your .xinitrc (found in your home directory).

  • I've just added the .xinitrc contents now, thanks. Jun 27, 2016 at 0:22
  • When you run "exec /usr/share/raspi-ui-overrides/applications/minecraft-pi" normally, does it lock up the console, or does it allow you to type immediately afterwards? Jun 27, 2016 at 0:34
  • I swapped minecraft with lxterminal since there wasn't a binary for minecraft to run at that location... Anyway, running "exec lxterminal" displays a message saying "cannot open display" and a bunch of text about the pi afterwards and immediately returns control (no blacking out). Running 'lxterminal' just displays "cannot open display". Running "startx lxterminal" produces a blackout that immediately disappears and text is printed regarding starting startx, with the last message being "lost connection to X server." It again immediately returns control. Jun 27, 2016 at 17:12
  • Hi. Any ideas about this? Jun 28, 2016 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.