1

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.

parovelb
  • 157
  • 7
  • Are there any actual error messages associated with "failed miserably" and "went bananas"? In general, you should make your question more focused. If you managed to start your script though lxsession autostart, and this is now broken, ask how to fix that, don't mention crontab and friends. If you want to switch to crontab or systemd, ask specifically about that. – Dmitry Grigoryev Feb 22 '21 at 14:28
  • @DmitryGrigoryev I mentioned crontab and friends to avoid proposing them as alternatives as they do not work. Unfortunately there are no errors visible that I could post, the app simply does not start. Thank you for the suggiestion about narrowing the question. – parovelb Feb 22 '21 at 14:53
  • Another point: does  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. – Dmitry Grigoryev Feb 22 '21 at 15:02
  • 1
    @DmitryGrigoryev, lxsessions is still running. – parovelb Feb 22 '21 at 15:59

3 Answers3

1

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.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
  • 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 Feb 23 '21 at 10:15
1

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.

parovelb
  • 157
  • 7
0

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

screenshot midnight commander