Headless Sonic Pi on Raspberry Pi

I have used this technique to run Sonic Pi headless. However it is not compatible with using VNCserver on the same Pi.
However with the latest OS, I boot (for example on a Pi400) with VNCserver enabled, but no monitor attached, and then I can either attach with a vnc client from my mac, or I send signals to SP via the cli gem as Ethan suggests. Note you can set SP to boot automatically by copying the desktop file to the autostart folder
cp usr/share/applications/sonic-pi.desktop ~/.config/autostart
Once you have SP running with your PiSound board, you can use the sonic-pi-cli to send a file of commands to sonic pi using sonic_pi "run_file '/path/to/filename'" The cli has to be running on the same pi, but it is possible to call it from a remote machine using a python script.
4 years ago I did quite a large project involving 2 PiSound boards and an iPad or iPhone running TouchOSC which shows what can be done headless. (the code probably needs slight tweaking to suit the latest OSC protocols in SP 3.3.1)

1 Like