Exported Linux app can't see its images when launched from AUTOSTART

please format code with </> button * homework policy * asking questions

I have an exported Linux application and can run it fine in Linux directly executing it, from a .desktop file in the Desktop folder, and from terminal using the complete path to it. I’m running this on Raspbian on a Pi 4 (I’m asking in this forum as it seems more of a general Linux coding question then Pi-specific)

When I have a .desktop file in /home/pi/.config/autostart it launches at boot as one would expect, but the resources it uses (images in it’s own folder) are not loading. I load images for the user GUI and they are a series of JPG’s in the app’s own folder (also work from DATA folder).

I use the same launch path in Exec= as I use in the other two methods, but for some reason the local resources are not loading. I added a Path= line to the .desktop file pointing to the app’s own directory (where it’s images are) to no avail. I also tried placing copies of the images it needs to load in the autostart folder in case it takes that as it’s working directory to no avail. In addition, if I quit my app, and then launch it by executing the same .desktop file in autostart manually, it all works, so perhaps this is a timing during the boot sequence issue rather than a location.

What am I missing? This is driving me nuts. I don’t want to hard-code locations for these images in the app, but may have to if I can’t resolve this. I’m sure I’m missing something simple as this should work.

Any suggestions are most welcome.

I don’t have Linux but
did you try to use sketchPath() or dataPath() ?

Maybe it helps your Sketch to find its stuff

println(sketchPath()); 
println(dataPath(""));
1 Like

I found the solution. It wasn’t a PATH issue after all, as hinted at by the issue not appearing when the .desktop is launched manually instead of automatically as part of the boot sequence.

I am using the Geomerative library, which loads images for GUI buttons which weren’t showing up for the party. I moved the call to the sub-routine that sets up these buttons and loads the images to as late in my void setup() routine as I could without compromising dependencies on it, and it now works.

Looks like the buttons were being formed before the system was ready to provide access to the images. Moving them later in the order of appearance apparently allows the system to catch up.

I would say this is an outlier case and I’m not thrilled with the workaround, but it now works reliably.

Thanks for the assistance in solving this one.

1 Like