I have a Python (Tkinter) GUI program that displays fullscreen and shows some pictures.

I want the following functionality: When the Pi is booted up, the python program is run with the appropriate display. Once it exits, the login screen is shown. Basically, the program should run before the login manager is called.

How should I go about setting this up?

(The reason I want this is that the Pi is going to be left on its own, if it reboots it should go into the app, but if someone exits the app they should not have access)

  • Do you want this to create a boot-up thingy? Dec 17, 2013 at 2:02
  • @RPiAwesomeness As in? I basically need to be able to leave the Pi connected to a monitor in such a manner that after boot up it shows the app without provocation, and if anyone should manage to make the program exit (which can be done by connecting a mouse and double-clicking in this case), the Pi should not be already logged in. Dec 17, 2013 at 2:09
  • As in showing a boot-up animation or splash screen. You basically want it to be a screen-saver/kiosk mode style thing until someone clicks on it? Dec 17, 2013 at 2:14
  • @RPiAwesomeness Yes. It is not intended to be clicked, however I don't want someone to come along, put in a mouse, click, and have full access to the Pi. Thus the Pi should not be logged in. Dec 17, 2013 at 2:25
  • 1
    Ah. I see, try taking a look at this, though it is just Chromium in Kiosk mode. Might help you along your way :D blogs.wcode.org/2013/09/… Dec 17, 2013 at 2:29

4 Answers 4


I believe that your RaspberryPi is already configured in (/etc/inittab) to start 5th runlevel. This way it knows that it should run graphical login manager just after booting. So you should find a line like this in your /etc/inittab (providing that you are using SLIM as a manager):

x:5:respawn:/usr/bin/slim >/dev/null 2>&1

Now what this line tells the system is that after starting in 5th runlevel, it should run /usr/bin/slim command. What you can do is to change this line in order to run your own program/script that will start X server and your Python script instead. This way, if someone kills your app, the script will end, it will be restarted and there will be no login prompt.

If, on the other hand, you want this login prompt to be visible, you can run slim in your script just after your program ends.

So, you could put something like this in your /etc/inittab (commenting slim line first):


Then you should create /usr/bin/start_my_script.sh with something like (substituting /path/to/your/program.py with a real path):

export DISPLAY=:0
xinit /path/to/your/program.py -- $DISPLAY
# if you want login prompt after exiting your script, uncomment this:
#/usr/bin/slim >/dev/null 2>&1

And make your script is executable by running:

sudo chmod +x /usr/bin/start_my_script.sh

I haven't tested this but I believe it should do the job.

  • For some reason my Pi wasn't set up to boot into the GUI login screen. And while I could set it up that way, I wasn't able to get the GUI login to come up. (slim was not there). I managed to work on your suggestion to make my own solution, which I'll post separately. The bounty still goes to you :P Dec 27, 2013 at 12:56

I think there might be a solution here. I don't really know whether it will work- have a look at the accepted answer:

Execute script on start-up


I'm not certain if this would work as I haven't tried it myself, but I believe you could follow this tutorial and simply use python <Path to script> in lieu of the omxplayer command. That article was linked from the main Raspberry Pi site a few weeks ago.

It basically details running a command during the boot. Here's what it said:

  • You will need to edit your /boot/cmdline.txt file:
    • sudo nano /boot/cmdline.txt
  • Add quiet to the end of the line. It will look something like this:
    • dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait quiet
    • Make sure that is all on one line.
  • Press ctrl-x, type y to confirm save, then press enter to return to the command line.
  • Copy your video Python program somewhere to the Raspberry Pi. I keep mine in /home/pi/ and call the video video.mov
  • You will now need to create a startup script that will run omxplayer your program at bootup. I have modified the script from the above link.
    • sudo nano /etc/init.d/asplashscreen
#! /bin/sh
# Provides:          asplashscreen
# Required-Start:
# Required-Stop:
# Should-Start:      
# Default-Start:     S
# Default-Stop:
# Short-Description: Show custom splashscreen
# Description:       Show custom splashscreen

do_start () {

    omxplayer /home/pi/video.mov &  # Change this line to 'python <path to your program>'
    exit 0

case "$1" in
    echo "Error: argument '$1' not supported" >&2
    exit 3
    # No-op
    exit 0
    echo "Usage: asplashscreen [start|stop]" >&2
    exit 3

  • Press ctrl-x, y to confirm saving, and press enter to return to the command line
  • Now you need to set the file to be executable
    • sudo chmod a+x /etc/init.d/asplashscreen
  • And activate it
    • sudo insserv /etc/init.d/asplashscreen
  • Sorry the code wasn't in the blockquote, I couldn't format it the way I wanted. :P Dec 27, 2013 at 17:10

On my system the GUI login was not the default screen to pop up. To make it work with the getty login, I did the following:

In /etc/inittab

  • Replace 1:2345:respawn:/sbin/getty --noclear 38400 tty1 with 1:345:respawn:/sbin/getty --noclear 38400 tty1

  • Add the line m:2:respawn:/usr/bin/runpygui.sh

Then I created /usr/bin/runpygui.sh:

export DISPLAY=:0
xinit /path/to/pythonprogram.py -- $DISPLAY
chvt 1
/sbin/getty --noclear 38400 tty1

I ran chmod +x /usr/bin/runpygui.sh and chmod +x /path/to/pythonprogram.py to make them both executables (pythonprogram.py needs to have the #!/usr/bin/python shebang at the top too).

Now, when it starts up after a brief period of scrolling startup text, the GUI program runs. On exit, tty1 is shown, with the usual text based login screen.

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.