Supercollider headless autostart and/or


did anybody have success to start supercollider (headless, sclang) automatically via cron or ?
i compiled supercollider on raspian-stretch with this instruction (scide)

its a bit odd. i never had the problem to automatically start sclang as root with cron job (crontab) on an raspbian-jessie-lite install.

but with this install crontab somehow does not work and i can only start sclang manually as user “pi”

pi@raspberrypi:~ $ sclang -D /home/pi/start.scd

or via my script

su pi -c "sclang -D /home/pi/start.scd"
pi@raspberrypi:~ $ sudo sh &

but as sudo or root i get an “…Could not connect to display localhost:10.0…”

pi@raspberrypi:~ $ sudo sclang -D /home/pi/start.scd
compiling class library…
MobaXterm X11 proxy: Unsupported authorisation protocol
QXcbConnection: Could not connect to display localhost:10.0

also spend some hours trying to start sclang in without success

thanks for any advice


I’ve been struggling with getting SuperCollider to start from the file as well. One thing I had to do was add and export DISPLAY variable to my startup script. I also had to source the script so that the variable would remain in the environment so that jack could start. Are you using jack? Here is my script that works when run as source

. /usr/local/etc/pisound/
export DISPLAY=:0.0
echo "Display Variable Set"
echo $DISPLAY 
/usr/bin/jackd -P75 -dalsa -dhw:1 -p64 -n3 -s -r48000 &
echo "Starting Jackd"
sleep 4
sclang -D /home/pi/mycode.scd &
echo "Starting SuperCollider"
flash_leds 255

I cannot howver get this script to work when assigning it to the button. The lights flash so I know the script works, but Jack or SuperCollider do not start. Let’s try to figure this out!


Did you try manually executing this script as root user? This could be the difference between it succeeding and failing when run through the button.

It may be helpful to redirect the stdout and stderr of jackd and sclang to some files you could access and investigate, by adding this to the commands:

/usr/bin/jackd -P75 -dalsa -dhw:1 -p64 -n3 -s -r48000 > /home/pi/jack.log 2>&1 &
sclang -D /home/pi/mycode.scd > /home/pi/sc.log 2>&1 &

The script is run as root, but your X session is almost certainly running as pi.

In this scenario, you need to ensure that root can have access to pi's X session. You’re half way there, you need one more environment variable:

export XAUTHORITY=/home/pi/.Xauthority
export DISPLAY=:0

If you want to the button to work, even when you are not logged into the Pi, you can run:

sudo raspi-config

and navigate to **Boot Options > Desktop / CLI" and choose Desktop Autologin. This will start up an X session, as pi on boot. Assuming you have a minimal X install (ask me how!) this won’t take up much CPU. (for me it is <1%).

@Giedrius: redirectin the stdout and stderr to log files is very helpful - thanks
@mzero: with the exports i managed to run sclang (supercollider) as root (great! thanks)

so tried to autostart supercollider with:

pi@raspberrypi:~ $ sudo crontab -e

@reboot /bin/bash /home/pi/ looks like this:

export XAUTHORITY=/home/pi/.Xauthority
export DISPLAY=:0
su root -c “/usr/bin/jackd -P75 -dalsa -dhw:1 -p64 -n3 -s -r48000 > /home/pi/jack.log 2>&1 &”
su root -c “sclang -D /home/pi/start.scd > /home/pi/sc.log 2>&1”

i could start sclang automatically with every “sudo reboot” for a while - but only with reboots

with boots sclang (log) complains:

No protocol specified
QXcbConnection: Could not connect to display :0

after a while sclang also complains after reboots

Invalid MIT-MAGIC-COOKIE-1 keyQXcbConnection: Could not connect to display :0

sometimes i can fix this with

grep ‘’ /etc/pam.d/* | awk -F “:” ‘{ printf “%s\t(%s)\n”, $2, $1}’

but the problem comes back

my other attempts to start sclang in /usr/local/etc/pisound/ with
“sh /home/pi/” or “sclang -D /home/pi/start.scd” result in this boost error message:

terminate called after throwing an instance of ‘boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::system::system_error >’
what(): assign: Operation not permitted

hmm… somehow im stuck

crontab isn’t going to be a reliable way to start this because it runs independently at boot from the processes that will start up the X server - which must be in place before you run sclang. This is because at each X startup the .Xauthority file is re-written with a random string (the cookie). If sclang starts first, the X lib will read the XAUTHORITY file at process start, and get a value from the previous X start.

If you are going to call sclang from either or, then do it like so:

nohup sclang .... > /tmp/sclang-log 2>&1 &

There is no reason to use the su root -c construct, since in both root’s crontab, and the pisound click scripts, they are already running as root.

hi mzero,

thank you for helping me with this.
i still don’t get nohup sclang in to work without that boost error.
but your hint that sclang needs to wait till Xserver is started helps a lot.
so i delayed the cron job about 20 seconds.

sudo crontab -e

@reboot sleep 20 && /bin/bash /home/pi/

and now its also starts with powering up the pi !

i think i am happy with this till i get sc with the button to work

best wishes

Hi All, Thanks for all the help. I feel like we’re close here. I can now get Jack to start from the button, but I get the same boost error with slang even when using nohup. What is the recommended way of getting rid of the boost error when using


Could you post the entire sc log when the exception occurs (if it’s a lot of output, you may post it to some pastebin service and link it here)? I found this post describing the same boost exception:

I am not sure where the difference of it working and not working via button scripts would come from though.

Sure, first here is the jack.log:
jackdmp 1.9.10 Copyright 2001-2005 Paul Davis and others. Copyright 2004-2014 Grame. jackdmp comes with ABSOLUTELY NO WARRANTY This is free software, and you are welcome to redistribute it under certain conditions; see the file COPYING for details JACK server starting in realtime mode with priority 75 self-connect-mode is "Don't restrict self connect requests" audio_reservation_init Acquire audio card Audio1 creating alsa driver ... hw:1|hw:1|64|3|48000|0|0|nomon|swmeter|soft-mode|32bit configuring for 48000Hz, period = 64 frames (1.3 ms), buffer = 3 periods ALSA: final selected sample format for capture: 32bit integer little-endian ALSA: use 3 periods for capture ALSA: final selected sample format for playback: 32bit integer little-endian ALSA: use 3 periods for playback

and then I can confirm that jackd is running by using top.

And here is the sc.log:
terminate called after throwing an instance of 'boost::exception_detail::clone_$ what(): assign: Operation not permitted

That’s the whole log. This is from pushing the button once.


Hi All, still haven’t been able to get this working. Any ideas on how to move forward?


Hi all, I finally installed Supercollider (through the very handy pisound-config app) and managed to get all audio + midi working (took me a while since i’m new to linux). I also made a script to run sc in headless mode. It works if I just execute it from the terminal but not through the button.

Here’s my script:

. /usr/local/pisound/scripts/common/

export DISPLAY=:0.0
flash_leds 1
sleep 0.5
flash_leds 20
sclang ~/Documents/SuperCollider/main.scd

In both cases (from terminal or through the button) the leds flashes but if I run it through the button the sc code doesn’t work.
Help would be much appreciated!

Just wanted to add that I followed the autorun instructions here:
and managed to get SC to run on startup. Still not with the button but this will do for now.

1 Like

Ive just fixed this exact problem on the Organelle …
this is cause because the headless operation of sclang does not like reassignment of the stdin.

Ive found that the workaround is to attach a pipe to the input

so what i do is something like :

(cd /home/pi/patch; echo " " | sclang start.scd & echo $! > /tmp/

this means that sclang has an stdin stream so is happy, but still executes start.scd.
most of this is sugar, but part of my normal practice, e.g. i like to run starts scripts in my patch directory, and also record the pid so that I’ve something to kill it later with :wink:


Thank you! Does this work when executing the script from the button?

I’ve not tested yet on pisound, but should do … it’s the same cause.
Btw: I’d also check to see if your sclang is using 100% cpu (via top) , if so that requires another fix.

Hi! Thanks so much for this help, but it’s not working with the pisound. I’m using the following script:

. /usr/local/pisound/scripts/common/

export DISPLAY=:0.0
flash_leds 1
sleep 5 #can be lower (5) for rpi3
(cd /home/pi; echo " " | sclang mycode.scd > /tmp/sclang.log)

when I run the above script manually on the command line the SC code works and I get a full log detailing SuperCollider’s startup.

However, if I start the script from the button, SC does not work and the log file only has one line in it:
“compiling class library…”

Any ideas why SuperCollider isn’t starting up fully when executing the script from the button?

Hi, I built sclang as written on under ‘Compiling SC natively on Raspberry Pi Raspbian Lite’ heading. (the sclang from apt-get doesn’t seem to be able to run in headless mode)

Then I ran the script as you showed with a couple of modifications:

  • adding killall sclang.
  • & at the end of the last line.
  • HOME variable initialization.
  • Removed sleep.
. /usr/local/pisound/scripts/common/

export DISPLAY=:0.0
export HOME=/home/pi
flash_leds 1
killall sclang
(cd /home/pi; echo " " | sclang mycode.scd > /tmp/sclang.log) &

Sleep may be useful if sclang would get started during boot time, but shouldn’t be necessary when starting using the button.

The & at the end of the last command is needed so that sclang is started as a background process, and the Pisound’s button doesn’t block until sclang is terminated - without it, it would become unresponsive until sclang exits. (I’m considering simplifying this and making all scripts executed by the button to be executed in background in future versions)

I had this in mycode.scd:

s.waitForBoot{ {[400, 404])}.play }

The contents of /tmp/sclang.log after clicking the button are:

compiling class library...
        Found 610 primitives.
        Compiling directory '/usr/local/share/SuperCollider/SCClassLibrary'
        Compiling directory '/usr/local/share/SuperCollider/Extensions'
WARNING: Could not open directory: '/home/pi/.local/share/SuperCollider/Extensions'
        To resolve this, either create the directory or remove it from your compilation paths.

ERROR: Class extension for nonexistent class 'HistoryGui'
     In file:'deprecated/3.9/'
        numentries = 1013163 / 11348984 = 0.089
        4106 method selectors, 2764 classes
        method table size 7046068 bytes, big table size 45395936
        Number of Symbols 11181
        Byte Code Size 303235
        compiled 355 files in 0.70 seconds

Info: 4 methods are currently overwritten by extensions. To see which, execute:

compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
Class tree inited in 0.06 seconds

*** Welcome to SuperCollider 3.9.0-beta1. *** For help type ctrl-c ctrl-h (Emacs) or :SChelp (vim) or ctrl-U (sced/gedit).
booting server 'localhost' on address:
Found 0 LADSPA plugins
jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
creating alsa driver ... hw:pisound|hw:pisound|128|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 128 frames (2.7 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
port created: Midi-Through:midi/playback_1
port created: Midi-Through:midi/capture_1
port created: pisound:midi/playback_1
port created: pisound:midi/capture_1
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 128
JackDriver: connected  system:capture_1 to SuperCollider:in_1
JackDriver: connected  system:capture_2 to SuperCollider:in_2
JackDriver: connected  SuperCollider:out_1 to system:playback_1
JackDriver: connected  SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
JackDriver: max output latency 5.3 ms
Shared memory server interface initialized
FAILURE IN SERVER /s_new Group 1 not found
Requested notification messages from server 'localhost'
localhost: server process's maxLogins (1) matches my options.
localhost: keeping clientID (0) as confirmed by server process.

And ps does show that there’s sc and jack processes running:

pi@raspberrypi:~ $ ps -ef
root     22679     1  0 12:47 ?        00:00:00 /bin/bash /usr/local/pisound/scripts/pisound-btn/ 1
root     22681 22679  1 12:47 ?        00:00:04 sclang mycode.scd
root     22705 22681  2 12:47 ?        00:00:06 scsynth -u 57110 -a 1024 -i 2 -o 2 -b 1026 -R 0 -C 0 -l 1
root     22712     1  7 12:47 ?        00:00:19 /usr/local/bin/jackd -T -ndefault -dalsa -r48000 -p128 -n2 -Xseq -D -Chw:pisound -Phw:pisound

However, I don’t get any audio output…

So it looks like on my system it gets further, not sure what’s different from yours.

Any ideas about the missing audio output?

1 Like

Thanks for doing all this! I think the issue is that the Default Group in SuperCollider doesn’t automatically get created when running from the command line. So add ‘s.initTree;’ after the waitforboot command in your mycode.scd file. And then I think you might get sound.

Hi All, I just tried to new startup script with the s.initTree line and it works! This is fantastic news. How can we contribute a new startup script for SuperCollider to the default Pisound software? It’d be great to have this all sorted out for everyone going forward.