# Changing Patchbox Modules with "The Button"

**URL:** <https://community.blokas.io/t/changing-patchbox-modules-with-the-button/3017>\
**Category:** Patchbox OS\
**Created:** [May 23, 2021, 12:45pm UTC](https://community.blokas.io/t/changing-patchbox-modules-with-the-button/3017 "2021-05-23T12:45:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Risher](https://community.blokas.io/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@Risher](https://community.blokas.io/u/Risher)\
**Post date:** [May 23, 2021, 12:45pm UTC](https://community.blokas.io/t/changing-patchbox-modules-with-the-button/3017/1 "2021-05-23T12:45:01Z")

</div>

Hello Community,

i’m trying to setup patchbox so that i can switch between different modules with The Button.  
I want to use the Modep module and alternatively switch to a custom module named “vcvrack”. I installed [VCVRack](https://vcvrack.com/) on my Pi as described here [https://github.com/hexdump0815/vcvrack-dockerbuild-v1](https://github.com/hexdump0815/vcvrack-dockerbuild-v1) and it works as advertised, though i have yet to check the performance.  
I made a custom script named `deactivate_module.sh` which i placed in the `/usr/local/pisound/scripts/pisound-btn` and bound it to HOLD\_3S in the `pisound-btn.conf` of each module i want to use (modep, vcvrack). Also `chmod` -ed it to make it executable.  
I proceeded the same way with two scripts named `change_modep.sh` and ‘change\_vcvrack.sh’ which i bound to CLICK\_1 and CLICK\_2 in the default patchbox OS setting of the button.  
The content of these scripts is just #!/bin/sh and then

```
. /usr/local/pisound/scripts/common/common.sh
patchbox module deactivate >/usr/local/pisound/scripts/pisound-btn/logdeactivate.txt

...

. /usr/local/pisound/scripts/common/common.sh
patchbox module activate modep >/usr/local/pisound/scripts/pisound-btn/logmodep.txt

...

. /usr/local/pisound/scripts/common/common.sh
patchbox module activate vcvrack >/usr/local/pisound/scripts/pisound-btn/logvcvrack.txt

```

When I’m calling these scripts manually by cd-ing into the folder and then starting them everything works as intended and the logfiles show the correct output. Also when I’m changing modules via the Patchbox UI, everything works just fine. But when pressing the Button to execute the scripts the process kind of breaks in unpredictable ways. The logfiles are created, but they are completely empty.  
When deactivating, the status of `patchbox module status` shows None, but the `patchbox button status` remains unchanged. Also i can still reach the MODEP-UI with other devices via Pi’s Hotspot. When i then deactivate the module (again) via patchbox UI, there are still services getting deactivated, which wouldn’t happen, when executing the scripts manually.

My guess is, it has something to do with the Button’s permissions.  
Does anyone have a solution for this issue? Maybe @Giedrius can help? I saw this post [https://community.blokas.io/t/the-button-user-and-permission/1249](https://community.blokas.io/t/the-button-user-and-permission/1249) but couldn’t really get to the ground of it.  
Any help would be appreciated 🙂

For reference: I’m working on a Pi 4 B, 4GB. I am also using a FanShim on my Pi as described in this post [https://community.blokas.io/t/pisound-with-raspberry-pi-4/1238/9](https://community.blokas.io/t/pisound-with-raspberry-pi-4/1238/9) and it works fine for me. (Didn’t install the FanShim Software because i read somewhere that it might conflict with the Pisound Button. So the fan just runs permanently, which produces a little noise, but is not really a problem for me). Also i activated the “pi 4 fix” described here [https://community.blokas.io/t/pisound-with-raspberry-pi-4/1238/12](https://community.blokas.io/t/pisound-with-raspberry-pi-4/1238/12) with `pisound-config`, because otherwise the pi wouldnt correctly boot with the FanShim and Pisound mounted.

---

<div class="post-metadata">

**Author:** ![Giedrius](https://community.blokas.io/letter_avatar_proxy/v4/letter/g/6a8cbe/32.png) [@Giedrius](https://community.blokas.io/u/Giedrius)\
**Post date:** [May 24, 2021, 8:01am UTC](https://community.blokas.io/t/changing-patchbox-modules-with-the-button/3017/2 "2021-05-24T08:01:18Z")

</div>

Hey, the Pisound’s set of button scripts get changed when switching Patchbox module, so that each module can have its own set of interactions, like when MODEP is up, it allows for switching between pedalboards, when PD is up, it restarts PD, searching for main.pd in defined search locations, etc…

I think this could be overridden without having to modify `patchbox` itself - if a config file path is specified for pisound-btn process, it overrides the PISOUND\_BTN\_CFG environment variable, which is used by `patchbox` for controlling the currently active button config.

You can force your own config to always be used:

```auto
# Make your own copy of the config that you can modify to your needs:
sudo cp /etc/pisound.conf /etc/my-pisound.conf

# Customize pisound-btn.service:
sudo cp /usr/lib/systemd/system/pisound-btn.service /etc/systemd/system/
sudo nano /etc/systemd/system/pisound-btn.service

# Edit ExecStart= line so it looks like this:
# ExecStart=/usr/bin/pisound-btn --conf /etc/my-pisound.conf

sudo systemctl daemon-reload
sudo systemctl restart pisound-btn

```

Now the `pisound-btn` should always use the scripts as set in `/etc/my-pisound.conf`.

The `patchbox` utility will still restart the `pisound-btn` when swtiching modules though, which may still interfere. In that case, `nohup` may have to be used in your scripts to disassociate the commands it executes from the `pisound-btn` process itself, so they’re not impacted by the service restarts.
