I'm at a loss at the moment with a problem regarding my bash script trying to convert midi input into key strokes using xdotool.

aseqdump -p "USB MIDI cable" | \
while IFS=" ," read src ev1 ev2 ch label1 data1 label2 data2 rest; do
    case "$ev1 $ev2 $data1" in
        "Note on 48" ) if[$octave=0] 
                           xdotool key 9; octave=1 
                         then xdotool key 1 
                           xdotool key 0; octave=1 
                       fi ;;
        "Note on 36" ) xdotool key 9; octave=0 ;;


for my problem: If I understand creating variables correctly, then pressing the key responsible for "Note 36" should set octave to 0 though the if statement on "Note 48" doesn't recognize it. in Addition even using a simpler

if[$octave=1] then xdotool key 1 fi ;;

Does not work with the variable provided.

sooo in the end what the script is supposed to do is convert midi input from a device to keystrokes though depending on the keys pressed beforehand the same key is supposed to output different keystrokes.

Additional Information

  • I am currently running on Ubuntu 22.04
  • The Keys are so far read and translated correctly, only the variable creates issues


Browse other questions tagged or ask your own question.