LesniakM
Posts: 3
Joined: Wed Aug 07, 2019 11:20 am

How to autostart both xinit/startx and python script

Sun Sep 22, 2019 2:20 pm

Hello there,

I'm using RaspberryPi and python graphical application to control some stuff. Critical for me is fast boot time. I'm using Raspbian Lite with some adjustments like disabling most of services etc, to aquire boot time less than 4 seconds.

However, my python app uses Tkinter, so it's need some kind of GUI. Normal desktop is to heavy for me, so I'm just using xinit or startx (both of them works fine.

So basicly, after boot I have to type in console:
xinit (or startx)
And then in newly opened xinit/startx console:
cd pythonApp/.../Main (just path to directory)
sudo python3 application.py

Btw, by some reasons if I'm trying to type 'sudo python3 pythonApp/.../Main/application.py', application won't start(occurs some problems with imports), when with 'cd pythonApp/.../Main' and then 'sudo python3 application.py' works fine...

How I can automate whole the process, to just power up RaspberryPi and have autostarted xinit with python script?
I know that I can run xinit with systemd, but that's not enough. Still I have to run commands 'cd pythonApp/.../Main' and then 'sudo python3 application.py'.

Fester Bestertester
Posts: 39
Joined: Wed Sep 25, 2013 9:04 pm

Re: How to autostart both xinit/startx and python script

Sun Sep 22, 2019 9:35 pm

Me too. I'd dearly like to see a config dialogue to add / delete programs to / from an auto-start sequence - and if poss to define :desktop # . I'd dearly like to be able to reboot/startup with Firefox on desktop 1 and Claws on Desktop 2 (I typically start with 4 available).
p.s. I'd also like Claws to auto-login and get latest from my (a defined?) account.. Firefox attempts to restore session.:)

bjtheone
Posts: 863
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: How to autostart both xinit/startx and python script

Mon Sep 23, 2019 7:43 pm

LesniakM wrote:
Sun Sep 22, 2019 2:20 pm
Hello there,

I'm using RaspberryPi and python graphical application to control some stuff. Critical for me is fast boot time. I'm using Raspbian Lite with some adjustments like disabling most of services etc, to aquire boot time less than 4 seconds.

However, my python app uses Tkinter, so it's need some kind of GUI. Normal desktop is to heavy for me, so I'm just using xinit or startx (both of them works fine.

So basicly, after boot I have to type in console:
xinit (or startx)
And then in newly opened xinit/startx console:
cd pythonApp/.../Main (just path to directory)
sudo python3 application.py

Btw, by some reasons if I'm trying to type 'sudo python3 pythonApp/.../Main/application.py', application won't start(occurs some problems with imports), when with 'cd pythonApp/.../Main' and then 'sudo python3 application.py' works fine...

How I can automate whole the process, to just power up RaspberryPi and have autostarted xinit with python script?
I know that I can run xinit with systemd, but that's not enough. Still I have to run commands 'cd pythonApp/.../Main' and then 'sudo python3 application.py'.
The first command should work if you supply a fully qualified path rather than a relative one. A fully qualified path starts from the root of the filesystem and likely is going to be something like /home/pi/pythonApp/...

JoPi123
Posts: 1
Joined: Mon Oct 14, 2019 8:45 pm

Re: How to autostart both xinit/startx and python script

Mon Oct 14, 2019 8:59 pm

Hi,
does someone solves the issue mentioned above. I get the same issue if I try to opne a python file with xinit.
I have mounted the linux installed path to "drv2" (where also the python script is placed) and try to start the gui script via:
sudo xinit <whole path to pythonfile>.py
but get some import failure, if I start xinit and browse to the python file and start it with python3 <pythonfile>.py in the xinit console it works fine.
Any hint would be great right now I have no idea how to fix it.
Thank you and regards
Joe

Return to “Advanced users”