We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've been trying to get a processing sketch to run automatically when the pi starts up - Pi 3b.
Pi is booting into the GUI. I'm using a simple sketch with no dependancies for tester PenroseTile from examples. Can't get it to work. I'm not great with Linux so maybe missing something basic. I'm trying to get this command to execute in a systemd .service file (rc.local approach didn't work either)
DISPLAY=:0 /usr/local/bin/processing-3.3.3/processing-java
--sketch=/home/pi/Desktop/PenroseTile/ --run > /home/pi/startup.log 2>&1 &
It works from command line with ssh from my computer. Boots up the sketch, but as ExecStart=
in the .service file I get nothing, not even the log file I'm trying to generate.
I've replaced the ExecStart string in the .service file to one that targets a python script and that works, so I think the .service file is setup correctly (/usr/bin/python /home/pi/Desktop/enviroFields/enviro3.py
works). I've noticed it doesn't seem to work if I try to execute a shell script from the .service file either ie /bin/sh /home/pi/Desktop/enviro.sh
won't run this way either.
I'm at a loss.
Is it that Processing sketch cannot be run by Pi at startup?
Should I Perhaps export as application? And how would I address it then?
Am I missing something in the command line construction?
Any pointers to existing documentation? I can't find anything that addresses this directly.
I just noted in forum post that Processing has a Jessie image. I'm not using that. I started with '2017-04-10-raspbian-jessie' set up with Kuman 5" display (HDMI). I installed Processing-3.3.3 directly.
Any help appreciated. Thanks
enviroFields.service file
[Unit]
Description=Start EnviroFields
After=multi-user.target
[Service]
Type=idle
ExecStart=DISPLAY=:0 /usr/local/bin/processing-3.3.3/processing-java --sketch=/home/pi/Desktop/PenroseTile --run > /home/pi/Desktop/enviroBoot.log 2>&1
[Install]
WantedBy=multi-user.target
Answers
Hi @poltergeister,
You are running Raspbian, right? Then the most convenient way to do what you want is the
~/.config/lxsession/LXDE-pi/autostart
file.You should be able to add a line like the following:
But if I remember correctly, output redirections won't work when done here. The solution here would be an extra shell script that runs the sketch (with >... and 2>&1), and invoking the script from within autostart.
Best
Yes on Raspbian. I think I understand. Run a shell script from LXDE-pi/autostart that initiates the processing sketch. I have that shell script working from desktop. But not clear on how to use the '>' directed output into another script. I think it also needs the display to be set 'DISPLAY=:0' which seems to confuse things sometimes. Let me give it a try firing off the desktop script.
@poltergeister You can use the ">" and "2>&1" to log the output into a file, as you did in the snipped posted above. This will work inside a shell script, but it won't work directly within autostart (hence the suggestion to invoke an extra bash script).
DISPLAY=:0 is only necessary outside an X session, e.g. over ssh.
Took look at & researched a bit on '.../autostart' file. The file seems to have links to various startup programs/routines, and searching web pages point to the 'init-d' approach to starting program which I can try.
Though there is one web page that seems to be talking about doing this on Pi. In this page they've created a directory in the same location (with name autostart) and put a 'app.desktop' in it to boot the app. Any thoughts? I'm not sure I know enough to manually set up the links in that '.../autostart' file, I have instructions on the 'init-d' approach.
DISPLAY... I see, tried it. The script executes differently if I'm in Terminal on Pi vs. in Terminal via SSH. Via ssh it needs display parameter. Is this an issue also, when/where shell script is run from system? Ie if shell script is called from outside it ie by debian/system, will it need 'DISPLAY' to not bomb?
So after all that angst above, I took a deep breath and simply copied the line you recommended into the .../autostart file and it worked fine. Thanks for the help.
Glad this worked out @poltergeister. (The UploadToPi tool for Processing also programmatically adds sketches to autostart in a similar way: https://github.com/gohai/processing-uploadtopi)
Could you tell me if I am doing something wrong here?
/usr/local/bin/processing-java --sketch=/home/pi/sketchbook/MYSKETCH --run
? Doesn't seem to be starting?
Is the path to your processing installation correct?
@koogs Not sure, how would I tell?
ls -l /usr/local/bin/processing-java
@koogs It seems correct - no error when I put that into terminal
@poltergeister - did you have to make your Processing file executable?
or perhaps I need to export the application?
Hmmm... been a while since I was working on this. - you didn't need to export the script as an application. It boots up Processing as long as file type is properly associated. - I don't recall if the sketch had to be executable. Perhaps the BASH script needed to be executable though. I don't recall the details.