G'day Giulio,
Thanks for all the details, it certainly gave me enough to try some things out. As I'm using all of Pepper's buttons in my patch and wanted to make sure I could use the bela cape button that I'd broken out to the front panel I didn't follow your instructions to the letter. Also, it's a PITA to remove and reinstall in the rack, so I'm trying to avoid having to update/flash or what have you. Anyway I think it's mostly working now - here's how I went about it.
I created a short script, similar to /opt/Bela/bela_button_hold.sh
called /opt/Bela/bela_button_click.sh
that contained make stoprunning command:
#!/bin/bash
#this file is executed when the button on the Bela cape is pressed momentarily
CUSTOM_FILE=/opt/Bela/local/`basename $0`
[ -f $CUSTOM_FILE ] &&\
{
echo "Bela button clicked, running $CUSTOM_FILE"
$CUSTOM_FILE
exit
}
echo Bela button clicked, stopping current project
make --no-print-directory -C /root/Bela stoprunning
Then, I updated /lib/systemd/system/bela_button.service
as such:
[Unit]
Description=Monitor the Bela cape button
After=networking-online.target
[Service]
Type=simple
ExecStart=/usr/bin/stdbuf -oL -eL /usr/local/bin/bela-cape-btn --pin 115 --click /opt/Bela/bela_button_click.sh --hold /opt/Bela/bela_button_hold.sh --delay 20 --monitor-click 1
Environment=HOME=/root
[Install]
WantedBy=default.target
Finally, I had to intercept the button press to stop csound from eating it, so I changed the /root/Bela/Makefile
csound command to:
RUN_COMMAND?=bash -c 'belacsound --stop-button-pin -1 --csd=$(CSOUND_FILE) $(COMMAND_LINE_OPTIONS) 2>&1'
And with that, I can cycle between the two csound patches I currently have running on the board with the bela button, thanks!
Might be problematic if I mix and match engines in my projects, but for now they're all csound.
Can you spot any foreseeable problems doing it this way?
Cheers