SpeedingPullet
Posts: 9
Joined: Tue Feb 16, 2016 11:33 am

Raspi3/Jessie/Pixel:autostart problem

Sun Mar 05, 2017 5:14 pm

Object: run a .sh file at startup to start a python program using PyQt.
Method: Edit ~/.config/lxsession/LXDE-pi/autostart
Add line @~/TWB3/RunTWB.sh
Problem: err,um, doesn't work.
I've tried: commenting out the xscreensaver line with a #
Putting the line at different points in the file.

Typing ~/TWB3/RunTWB.sh at the command line works.

OS: Jessie with Pixel on a Pi3.
This is all the more irritating because (with another forum member's
help) I managed to autorun a similar program under Wheezy on an earlier
model of Pi.
Suggestions welcomed!

gordon77
Posts: 3026
Joined: Sun Aug 05, 2012 3:12 pm

Re: Raspi3/Jessie/Pixel:autostart problem

Sun Mar 05, 2017 6:23 pm

Do you need @sh ~/TWB3/RunTWB.sh?

SpeedingPullet
Posts: 9
Joined: Tue Feb 16, 2016 11:33 am

Re: Raspi3/Jessie/Pixel:autostart problem

Sun Mar 05, 2017 6:58 pm

Thank you, gordon77, but I'm afraid that doesn't start my program.

User avatar
KLL
Posts: 1122
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Raspi3/Jessie/Pixel:autostart problem

Mon Mar 06, 2017 8:03 am

possibly the ~/TWB3/RunTWB.sh starts, but
can not do what is inside?
did you test it ( command line ) from a different path already?
best practice is

Code: Select all

#!/bin/bash
MYPATH='/home/pi/TWB3/'
MYPROG='my_app.py'
#echo '10s'
#env sleep 5s
#echo '5s'
#env sleep 5s
echo 'start python ... , stop with [ctrl][c]'
cd $MYPATH
sudo /usr/bin/python3 $MYPATH$MYPROG

User avatar
startrek.steve
Posts: 362
Joined: Thu Aug 30, 2012 7:19 pm

Re: Raspi3/Jessie/Pixel:autostart problem

Mon Mar 06, 2017 8:37 am

I had this problem when I upgraded my Pi3 to Pixel. I autostarted in cron with @reboot /home/pi/./conky.sh

That seemed to work ok
Pi 2 running LibreElec Krypton, Pi 2 running Wheezy Desktop, Pi 1 headless Wheezy, downloading Radio, Pi 1 running Picore headless Media Server, Pi Zero to be an Old Time Radio Project. Pi 3 testing. Pi Zero W downloading Radio shows headless.

SpeedingPullet
Posts: 9
Joined: Tue Feb 16, 2016 11:33 am

Re: Raspi3/Jessie/Pixel:autostart problem

Mon Mar 06, 2017 1:19 pm

Thank you everybody.
I eventually succeeded with
@python /home/pi/TWB3/twb.pi
as the penultimate line in the autostart file. Contrary to some comments on other postings on similar topics, I didn't need to comment out the screensaver line.
Again, my thanks to all.

k-pi
Posts: 191
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Raspi3/Jessie/Pixel:autostart problem

Mon Mar 06, 2017 3:46 pm

Using the full path to your programs will always help when trying to auto start them.

SpeedingPullet
Posts: 9
Joined: Tue Feb 16, 2016 11:33 am

Re: Raspi3/Jessie/Pixel:autostart problem

Mon Mar 06, 2017 6:51 pm

Update: while my previous stated solution did indeed start the GUI of the program, it did not respond to key presses. However, calling a .sh file based on KLL's suggestion gives completely satisfactory operation.

beto2d
Posts: 7
Joined: Tue Apr 04, 2017 7:37 pm
Location: Baltimore, MD USA

Re: Raspi3/Jessie/Pixel:autostart problem

Wed May 03, 2017 2:30 pm

I've been having issues with this as well. I got a newer raspberry a month ago, and tried to duplicate something I did with a Raspberry I bought in January. I'm trying to start a python program after pixel reaches the desktop.

For some reason altering the LXDE-pi autostart file with:

Code: Select all

@usr/bin/python home/pi/myscript.py 
This did not work.


On the newer one I had to go with:

Code: Select all

@lxterminal -e python home/pi/myscript.py
This worked on the newer raspberry.

The .py is an executable and everything should be in order. This worked perfectly on the first raspberry. It seems like the usr/bin/python files can only be executed in terminal.

What is the difference here? There shouldn't be anything wrong with @usr/bin/python. I used last line of the autostart file for both versions.

I

connectable
Posts: 7
Joined: Tue Sep 01, 2015 5:34 am

Re: Raspi3/Jessie/Pixel:autostart problem

Tue Sep 19, 2017 6:04 pm

WRT to current problems with autostart. This has had me tearing out my hair. Comments on other blogs referring to unnecessary and undocumented changes in the autostart function on Raspbian appear to be studiously ignored by the implementation team.
Command lines that SHOULD work, and do work - as command lines, especially those using @lxterminal, usually result in a fleeting glimpse of an empty lxterminal, and no program/shell launch.
I can confirm that the later comments in this topic contain correct advice, based on my own findings.
Below I quote the launch of a socket server written in python3, which successfully reports progress to the terminal, after launching at restart.

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@lxterminal -e python3 /home/pi/radserverv1.4.py server 192.168.1.121
Some observations:
1 - IGNORE man page for lxterminal which implies a STRING for command list. (IOW DON'T quote it!)
2 - IGNORE advice urging preceding python or python3 with ‘/usr/bin/’.
3 - Make the (autostart) file executable by everyone.
4 - Make the (autostart) file belong to group/user pi:pi
5 - IGNORE advice about deleting splash screen etc. In fact, ignore ANY advice preceding 2017 – it will probably be wrong for this (jinxed) :twisted: jessie.

User avatar
KLL
Posts: 1122
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Raspi3/Jessie/Pixel:autostart problem

Wed Sep 20, 2017 3:20 am

you might include what file you talk about ?
nano /home/pi/.config/lxsession/LXDE-pi/autostart

and you sure mean the same file ??
connectable wrote:3 - Make the (autostart) file executable by everyone.
or you mean your python program?
if bash or python same,
-a-
if you call it myprogram.py myscript.sh .. is up to you
-b-
if you want start it with
./myprogram.py
./myscript.sh
you need
-b1- to make it executable chmod +x ...
-b2- you need in the first line like #!/usr/bin/python3 #!/bin/sh
-c-
if you start it with
python3 myprogram.py
bash myscript.sh
not need any of that.

Return to “Beginners”

Who is online

Users browsing this forum: brouno and 42 guests