How do I debug program that only crashes on autostart?

Please post all general support questions for LXDE here.
Locked
jwatte
Posts: 3
Joined: Thu Nov 29, 2012 5:21 pm

How do I debug program that only crashes on autostart?

Post by jwatte »

I'm using raspbian, which uses LXDE. I've asked on the raspberry pi forums, but didn't get an answer; likely this is LXDE specific more than Raspberry Pi specific.
I have configured automatic login on boot, and this has worked for a long time.

I have created a .desktop file for a simple utility I wrote in python2 and pygame.
When I start the utility from the command line, it works great.
When I start the utility by double-clicking the .desktop file in pcmanfm, it works great. (The name is voltman.desktop)
I have put a symlink to this file into the .config/autostart directory in my home directory.
The desktop file is found by the "desktop session settings" control panel, and is checked there.
When the system auto-starts, the desktop environment starts up, see the window of my utility briefly show up, and then it immediately dies.

I have a second .desktop link in the autostart folder, to lxterminal.desktop, and this starts fine. (It did so even when it was the only autostart .desktop file, so it's not "the first autostart doesn't work.")

I have looked for log files in /var/log and /home/pi, but I have not found anything that mentions the voltmon.desktop file, or the reason why it may be crashing.
I'm looking first of all for help on where to find these log files, and barring that, how to diagnose this problem. If someone knows exactly what the problem is, I'd take a direct solution, too.

Here is the .desktop file:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Name=VoltageMonitor
GenericName=VoltageMonitor
Comment=Show how much juice is in the battery
Path=/usr/local/src/voltmon/
Exec=python /usr/local/src/voltmon/test1.py
Icon=/usr/local/src/voltmon/battery.png
Type=Application
Categories=Utility,Programming
Also of curiosity: I've put this file in .local/applications/ (I had to create that directory) but it doesn't show up in the applications menu. That's the location that the documentation on desktop files suggested; is there another place it should go?
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: How do I debug program that only crashes on autostart?

Post by seppalta »

Try putting a copy of voltagemonitor.desktop into ~/.config/autostart.
jwatte
Posts: 3
Joined: Thu Nov 29, 2012 5:21 pm

Re: How do I debug program that only crashes on autostart?

Post by jwatte »

Thank you for the answer. Just to be sure I understand your suggestion: Are you saying that there is a difference between "symlink" and "actual file copy"?

I tried that, and it doesn't help. It still starts up, shows the window, and immediately shuts down.

Therefore, I would like to know how to debug a program in the autostart environment.
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: How do I debug program that only crashes on autostart?

Post by seppalta »

There can be 5 or more autostart file-folders with an LXDE desktop. See http://lxlinux.com/#4 for more details. I found /etc/xdg/lxsession/LXDE/autostart to be the most reliable when I have the full desktop. With just Openbox, putting a .desktop file in ~/.config/autostart usually does the job. Alert all of them - maybe you will end with 3 or 4 copies opened. It shouldn't harm anything :D .

Oh, yes, symlink should work the same, but sometimes the real thing works better!
rvan2012
Posts: 2
Joined: Mon Aug 18, 2014 1:31 pm

Re: How do I debug program that only crashes on autostart?

Post by rvan2012 »

Some other things to try:
  • $HOME/.local/share/applications/ adds to the menu
  • use full path for python ie. "Exec=/usr/bin/python /usr/local/src/voltmon/test1.py" OR
  • put a hash-bang in the .py file, chmod +x it and drop the python call
  • run it in a terminal to get a brief glimpse of why it might be crashing, add a line "Terminal=true"
Locked