Auto run sketch on raspberry pi 5 on reboot

I’m trying to get 6 pi5s to, on startup, run their sketches.

I’ve got six different projectors high up with a pi generating visuals for each projector and I need the pi’s -on power up to run the sketch.pde (which are full screen) and hide the pi’s menu bar fully. Any suggestions?

I’m sending OSC data from an M1 MacBook Sonoma.

If I vnc in I can choose terminal and start processing then choose file open to get the sketch running but I’d like to get the sketch playing by default.
Thanks

1 Like

Hi @enki and welcome to the forum!

Fair warning: I haven’t tested the following approach but this is what I have understood from this thread on the old Processing forum. This is assuming you are using Raspbian.

First, create a shell script (let’s call it run_sketch.sh) to launch your sketch. It should looks something like this:

#!/bin/bash
/usr/local/bin/processing-java --sketch=/home/pi/sketchbook/sketchname --run > /home/pi/sketchlog.txt 2>&1

This will run your sketch and log any output or errors to sketchlog.txt.

Next, to make your sketch run at startup, edit the autostart file located at /home/pi/.config/lxsession/LXDE-pi/autostart and add the following line:

/home/pi/run_sketch.sh

With this setup, your Raspberry Pi will automatically run the Processing sketch on boot.

For alternative approaches, see this Sparkfun tutorial.

Let me know if this works!

4 Likes

For general info on running startup program on raspberry pi, can find tutorials by googling “raspi kiosk mode”. Most of the tutorials show how to open chromium but you can replace it with your processing sketch. For example, official doc:

https://www.raspberrypi.com/tutorials/how-to-use-a-raspberry-pi-in-kiosk-mode/

7 Likes

Really useful link! That does depend on using Wayland though. I’ve currently switched my Pi5 to use X11 as some Java things are rendering much slower through Wayland. It’s probably worth making sure you get comparable / suitable performance before relying on that method.

1 Like