Skip to content

Instantly share code, notes, and snippets.

@indeedwatson
Created July 10, 2020 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indeedwatson/eb443fdb9396626389fe0ba1ccc2cc49 to your computer and use it in GitHub Desktop.
Save indeedwatson/eb443fdb9396626389fe0ba1ccc2cc49 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Replace with your controller model
KB_MODEL="BK492"
# check if jack and a2jmidid are active
if jack_control status && (a2j_control --status | grep "enabled"); then
# kill any previous instances of fluidsynth
for id in $(pidof fluidsynth); do
kill $id
done
MIDI_KB=$(jack_lsp | grep -P "$KB_MODEL \[\d\d\] \(capture\)") ||
MIDI_KB=$(jack_lsp | grep -P "Midi Through \[\d\d\] \(capture\)")
if [ -z "$MIDI_KB" ]
then
dunstify "Is your midi keyboard on?" "$KB_MODEL\n"
exit
fi
termite --name piano -e "fluidsynth -a jack -j \
$HOME/soundfonts/KawaiUprightPiano-20180102.sf2" &
sleep 2
FLUID=$(jack_lsp | grep -P "FLUID Synth \(\d*\) \[\d*\] \(playback\)")
echo $MIDI_KB $FLUID
jack_connect "$MIDI_KB" "$FLUID" &&
dunstify "Keyboard connected succesfully" "$KB_MODEL"
else
dunstify "jack and a2j not started"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment