I have the following problem: Using a RaspPi 3B running Raspbian Jessie (version 4.4.26-v7+) I would like the GUI of a self-written python script to be executed on startup.
I know that this question has been asked on this website as well as on others, but as Raspbian keeps changing and none of the solutions suggested before worked for me (see below), I would like to ask it again.
From my understanding, I need to load XServer and execute my script afterwards. This should happen instead of loading the whole desktop.
One way of achieving this is supposed to be via the LXDE autostart file (as outlined in this answer). I edited the file /etc/xdg/lxsession/LXDE-pi/autostart
as well as the file /etc/xdg/lxsession/LXDE/autostart
(the former originally contained four lines instead of three as suggested in the post referenced) - adding the lines @sudo python /full/path/to/file.py
and @openbox
, but my Pi still boots into the desktop and does not automatically execute the script at all. Annotation: I tried just the script line and the script line together with the openbox line for either one of the files and for both files together.
Another strategy involves the rc.local file (as suggested in the official documentation). However, only adding python /full/path/to/file.py &
did not work (as there still was my GUI missing) and further adding startx
didn't help as I apparently could not link the startx with the python script and the former therefore closed immediately after it started.
Some suggest, that (additionally) .xinitrc should be used. This, however, did not work either:
su -c python /full/path/to/file.py pi
And, last but not least, in some way, it should be doable using init.d - but I haven't found details on this, yet.
I would really appreciate any hint towards the right direction. Where is my mistake? How should my line in rc.local or .xinitrc look like? Or have there been major changes related to the switch to pixel and I should try something else?
Some additional information: The script needs sudo rights. It is written in Python 2.7, the GUI is using Tkinter. The GUI fills the screen completely, so backgrounds are irrelevant. The script is supposed to run forever (or until it is stopped by user input through the GUI) and uses system services like wifi and ethernet.
More information: All is happening locally.
Clarification: By now I spent more than 8 hours searching the net, trying out tutorials from different starting points or mixing them together. I came to the conclusion, that either my script (which works perfectly when started in pixel) does not work if run in a non-desktop environment (which I doubt) or that a new tutorial is needed, because the October 2016 changes to Raspbian made any older tutorials obsolete. Furthermore, the challenge lies not in starting the script or starting Xserver (or something similar) independently from each other, but in doing both linked so that the script will use the display created by Xserver.