the script is called from
/home/pi/.config/lxsessions/LXDE-pi/autostart with the line:
@bash /home/pi/Documents/openContent.sh /media/pi index.html http:/google.com
and openContent.sh is:
#!/bash # $1 defines path we search # $2 defines name of file we're searching for # $3 defines default URL if we can't find the thing we're searching for path="$(find $1 -name $2 | head -n 1)" if [ -f "$path" ]; then echo "content found at $path" chromium-browser --incognito --kiosk $path exit else echo "content was not found in $1 chromium-browser --incognito --kiosk $3 fi
When i run the script from terminal after startup, it works as expected. If i search with the same arguments, it will open the webpage from USB. If i give it a random name to search for that isn't there, it will open google.com (since it can't find it in /media/pi. That's all good
However, when rebooting and running from autorun, it will invariably go to google.com. If i substitute the line:
@sh /home/pi/Documents/openContent.sh /media/pi index.html http:/google.com
@chromium-browser --incognito --kiosk /media/pi/DISK_IMG/index.html
it opens the page - so it doesn't seem to be an issue of the USB drive loading late or I would expect neither to work.
I figure that this is just something i'm doing wrong with the bash script or passing arguments in the autostart, but I don't know what. Any ideas?
I tried adding a
sleep 30 to the top of openContent.sh and it worked. this is a little disturbing because I really don't want to hard-code a delay in there. Is this a known issue with find/ USB devices, that they load some time after the GUI/desktop environment?
It kind of makes sense because basically chromium can't actually try looking at the dir until the file system is ready, so if i pass it an explicit URL, it'll trust me and go there and by the time it gets around to looking there, the file system is ready, but if i search first, the results tell me there's nothing there.