# Auto run sketch on raspberry pi 5 on reboot

**URL:** <https://discourse.processing.org/t/auto-run-sketch-on-raspberry-pi-5-on-reboot/45164>\
**Category:** Processing for Pi\
**Created:** [October 11, 2024, 4:42am UTC](https://discourse.processing.org/t/auto-run-sketch-on-raspberry-pi-5-on-reboot/45164 "2024-10-11T04:42:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![enki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/enki/32/20047_2.png) [@enki](https://discourse.processing.org/u/enki)\
**Post date:** [October 11, 2024, 4:42am UTC](https://discourse.processing.org/t/auto-run-sketch-on-raspberry-pi-5-on-reboot/45164/1 "2024-10-11T04:42:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [October 11, 2024, 5:46pm UTC](https://discourse.processing.org/t/auto-run-sketch-on-raspberry-pi-5-on-reboot/45164/2 "2024-10-11T17:46:18Z")

</div>

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](https://forum.processing.org/two/discussion/22968/start-processing-sketch-at-pi-startup.html) 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:

```bash
#!/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:

```auto
/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](https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup#method-2-autostart).

Let me know if this works!

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [October 12, 2024, 3:11pm UTC](https://discourse.processing.org/t/auto-run-sketch-on-raspberry-pi-5-on-reboot/45164/3 "2024-10-12T15:11:57Z")

</div>

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/](https://www.raspberrypi.com/tutorials/how-to-use-a-raspberry-pi-in-kiosk-mode/)

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [October 16, 2024, 10:25am UTC](https://discourse.processing.org/t/auto-run-sketch-on-raspberry-pi-5-on-reboot/45164/4 "2024-10-16T10:25:23Z")

</div>

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.
