Created
May 4, 2020 12:42
-
-
Save grachevko/1cd90729a481feff3d35c190a62f4433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RULE_FILE=/etc/udev/rules.d/00-keystation-88.rules | |
SERVICE_FILE=/etc/systemd/system/keystation88.service | |
SCRIPT_FILE=$(realpath "$0") | |
install() { | |
cat >$RULE_FILE <<EOL | |
KERNEL=="dmmidi2", SUBSYSTEM=="sound", RUN+="$SCRIPT_FILE event" | |
EOL | |
udevadm control --reload | |
cat >$SERVICE_FILE <<EOL | |
[Unit] | |
Description=fluidsynth | |
[Service] | |
ExecStart=$(which fluidsynth) -i -s -a alsa -g 1 /usr/share/sounds/sf2/FluidR3_GM.sf2 -o audio.alsa.device=hw:1 | |
ExecStartPost=/bin/sh -c 'while ! (aconnect -o | grep FLUID) </dev/null >/dev/null 2>&1; do sleep 0.2; done' | |
ExecStartPost=$(which aconnect) 24 128 | |
[Install] | |
WantedBy=multi-user.target | |
EOL | |
systemctl daemon-reload | |
} | |
uninstall() { | |
rm -rf $RULE_FILE | |
udevadm control --reload | |
rm -rf $SCRIPT_FILE | |
systemctl daemon-reload | |
} | |
start() { | |
systemctl start keystation88.service | |
} | |
stop() { | |
systemctl stop keystation88.service | |
} | |
case "$1" in | |
install) install ;; | |
start) start ;; | |
stop) stop ;; | |
event) if [ "add" == "${ACTION}" ]; then | |
start | |
else | |
stop | |
fi;; | |
*) | |
echo "usage: $0 install|start|stop|uninstall" >&2 | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment