Heikki Ketoharju

Session management in Linux

This is a session management script I did for our band's gig. It worked pretty well, but I just thought maybe I should try to find something a little bit more modern? Mac users have Main Stage and stuff, and I'm just writing poor old BASH scripts. Luckily writing these is quite fun!

This script captures pids of all the processes it executes. That way I can kill every process individually. Nice! All the connections are made by QJackCtl Patchbay.

What do you think about this? And what session management I should try? Jack Session really didn't work because many programs lack support for it.

!/bin/bash

cd /media/data/archtest-home/heikki/

a2jmidid dbus service with hardware ports enabled

a2j -e &

this starts the Mididings script

./studio/harmainvalta_livesetup.mididings & MIDIDINGS_PID=$!

xdotool set_desktop 1

mididings-gui. -T option makes it look better ;-)

livedings -T & LIVEDINGS_PID=$!

sleep 1

xdotool set_desktop 4

linuxsampler& LINUXSAMPLER_PID=$!

qsampler synat/GIGS/harmainvalta2.lscp & QSAMPLER_PID=$!

qsynth --midi-driver=jack & QSYNTH_PID=$

sleep 1

xdotool set_desktop 1

echo -e "\n\n\n####################################################" echo -e "#  WELCOME TO HARMAINVALTA LIVE SETUP CONSOLE!     #" echo -e "#################################################### \n\n"

while [ 1 ]; do

    echo -e "\n\nPress q to quit, p to see current processes"     echo -e "r to restart a2jmidid, m to restart mididings, a to run start sequence ";     # lets read the key press to $key variable:     # -e means that after input comes a line feed and     # -n 1 reads just one key without waiting enter.     read -e -n 1 key     echo -e "\n\n"

    if [ $key == "q" ] || [ $key == "Q" ]; then         echo "Are you sure you want to quit? [y/n]"         read -e -n 1 key         if [ $key == "y" ]; then             break;         fi     elif [ $key == "p" ] || [ $key == "P" ]; then         jobs     elif [ $key == "r" ] || [ $key == "R" ]; then         killall -9 a2jmidid         a2j -e &         sleep 1     elif [ $key == "m" ] || [ $key == "M" ]; then         kill $MIDIDINGS_PID         ./studio/harmainvalta_livesetup.mididings &         sleep 1         MIDIDINGS_PID=$!     elif [ $key == "a" ] || [ $key == "A" ]; then         echo "Are you sure you want to run start sequence? [y/n]"         read -e -n 1 key         if [ $key == "y" ]; then             mplayer -ao jack -volume 35 "./samplet/MINA LAHDEN YKSIN.wav"         fi     fi

done

killall -9 a2jmidid kill $QSYNTH_PID kill $LINUXSAMPLER_PID kill $QSAMPLER_PID kill $LIVEDINGS_PID kill $MIDIDINGS_PID

echo -e "\nLivesetup terminated! Have a nice day!"

The only problem I really had with this was that at the last time Intro sequence didn't start. I think mplayer isn't the best option for playing raw wavs through Jack.