Search code examples
raspberry-pikivyshraspbian

Execute a kivy Script on start up of the raspberry


I would like to execute a python script launching a kivy App at the start up of the Raspberry pi. One little particularity is that I use a workaround to launch my kivy app (see this thread on kivy's github and especially, this response)

My script is really basic as you can see (and it's working) :

#!/bin/sh

./kivyrun /home/pi/Desktop/interfacebancdetest_dev/main.py

What I already tried

I followed this tutorial, and created an "LPBM.desktop" to /home/pi/.config/autostart/

my script

[Desktop Entry]
Type=Application
Name=LPBM
Exec=/home/pi/Desktop/LPBM.sh

but it didn't work...

I also tried to modify my /etc/rc.localand I added /home/pi/Desktop/LPBM.shbefore the exit 0 but once again it didn't work either so i'm little bit stuck...


Solution

  • You should be able to start your script directly from the autostart file.

    One thing to bare in mind is that the autostart location may be different depending on what user you're logged in as. For example, with a default Raspian install the local path for the LXDE desktop environment autostart file currently would be:

    ~/.config/lxsession/LXDE-pi/autostart
    

    If you add an entry prefixed with @ it should launch the script for you. In my experience the using absolute paths were most stable.

    In your case you're locally calling ./kivyrun, but you can use which kivyrun to find out where it's installed. After that all that's left is to point kivyrun to your script, for example:

    @/absolute/path/to/kivyrun /home/pi/Desktop/interfacebancdetest_dev/main.py
    

    Where /absolute/path/to/ would get swapped out with the absolute path returned by which kivyrun previously