It will be very slow and I don’t think holding down the button for big changes will work out too well, but you can keymap a button to run a python script. If you need to run a bash script you would have to make a python script that calls the bash script like…
import subprocess
cmd = '/bin/bash /home/osmc/script_down.sh'
results = subprocess.run(
cmd, shell=True, universal_newlines=True, check=True)
print(results.stdout)
The keymap would be something like…
<?xml version="1.0" encoding="UTF-8"?>
<keymap>
<Global>
<keyboard>
<volume_down>RunScript(/home/osmc/script_down.py)</volume_down>
</keyboard>
</Global>
</keymap>
Keymap reference [here]
It might be a bit more sane to just use multichannel PCM instead of passthrough and use Kodi’s volume control if CEC isn’t an option. The remote can’t send IR as it is RF only and basically just acts like a keyboard would.