I have Raspbian Buster on a RPi4 and I was launching a Python3 based Kivy 2.0 app at startup. Since it is a GUI app that needs networking and bluetooth. The only way to make it work was an executable script with sudo chmod +x myapp.py
and add the line @python3 ~/myapp.py
to /etc/xdg/lxsession/LXDE-pi/autostart
.
Later on I installed Teamviewer and at the startup the app simply does not start any more. I have checked all the LXDE-pi autostarts, configs, desktops, lxpanels, lxsessions, xdges without finding a flaw. The only change I found was teeamviewer added a service in etc/systemd/system
. Uninstalling teamviewer did not help.
Any suggestions?
UPDATE n.1
The file /home/pi/.config/lxsession/LXDE-pi/autostart
does not exist so it is not used instead of /etc/xdg/lxsession/LXDE-pi/autostart.
In $HOME/.config/lxsession/LXDE-pi/desktop.conf
the part disable_autostart=no
, so it should be fine.
My app launched only using lxsessions/autostart
. Other attempts such with rc.local,autostart desktop files, systemd, crontab,init.d and bashrc did not have a positive outcome and I can not consider them as solutions.
UPDATE n.2
Teamviewer is not guilty. I tested with a simple script and lxsessions
does run after boot.
The script myapp.py works fine when launched any time except after reboot. After checking /home/pi/.cache/lxsession/LXDE-pi/run.log
it seems to be a serial tty port problem. This is the post where I found out about run.log
raspberry-pi-autostart-of-lxde-does-not-work.
3 Answers 3
I suggest you try adding a simple app to your autostart file, e.g. leafpad
, just to make sure it is still in use. If Leafpad won't run, you'll have to concentrate on your desktop environment / session configuration. Perhaps checking log files in /home/pi/.cache/lxsession/LXDE-pi
will shed some light on the situation.
Otherwise, the problem is in your script. I would replace ~/myapp.py
with an absolute path to be sure, and then add some code to it which logs the progress to a file.
-
I tested with a simple script and
lxsessions
does run after boot. It seems to be a problem with opening a serial tty port right after boot.parovelb– parovelb2021年02月23日 10:15:46 +00:00Commented Feb 23, 2021 at 10:15
When launched my script initializes the serial ports ttyACM*. After failing with lxsession/LXDE-pi/autostart
I went to see the lxsession autostart log .cache/lxsesion/LXDE-pi/rpi.log
. I found out my script was not able to open the serial port only at startup, right after boot. It was not a matter of permissions or timing. After playing with crontab
, bash
and lxsession
, I removed sudo apt-get purge modemmanager
as suggested in the Arduino forum and now my script works as expected.
Although this topic is not new, the autostart problem resurfaced newly again. The fact that Conky was not auto-starting anymore, made me aware of this new issue.
After some unsuccessful efforts by using the latest hints that I found on the web, I tried:
/home/myusername/.config/autostart-scripts
by adding a symlink to a shell-script (see image below) . The script:
#!/bin/bash
stat='df -h' # get status of mounted drives
$stat > ~/startstatus # and (over)write to file startstatus
stat2="sudo systemctl status home_autom" # get the status of service
$stat2 >> ~/startstatus # and append to above file
sleep 45
conky -obdq # start conky
Now conky pops up again at boottime. By checking the modification date of the file startstatus can be verified whether the script worked or failed.
My system: Raspberry 3 B+ Linux raspi10 5.10.52-v7+ #1441 SMP Tue Aug 3 18:10:09 BST 2021 armv7l GNU/Linux Raspbian lite + KDE
lxsession
autostart, and this is now broken, ask how to fix that, don't mentioncrontab
and friends. If you want to switch tocrontab
orsystemd
, ask specifically about that.lxsession
still run, or did it get removed / disabled when you installed Teamviewer? And BTW,systemd
or a.desktop
may be a good alternative, despite the fact you couldn't set it up before.lxsessions
is still running.