#!/bin/bash
# Neat script to make menu-driven life easier for ardour users.
# Austin Acton, 2003.

# Check for various dialog types, prefer kde, then gnome, then X, then text. (Buchan Milne)

COMMAND="$TERM -e dialog"
[ -x "`which Xdialog 2>&-`" ] && COMMAND="Xdialog"
[ -x "`which gdialog 2>&-`" -a -n "$GNOME_DESKTOP_SESSION_ID" ] && COMMAND="gdialog"
[ -x "`which kdialog 2>&-`" -a "$DESKTOP" == "kde" ] && COMMAND="kdialog"

# Main works like this:
# 1. If jackd running, just start ardour (keep expert/cli users happy).
# 2. If not, check for (and run) qjackctl, and tell the user to start jack with it.
#    Then wait for OK, then run ardour.

if [ "`ps -A | grep 'jackd'`" != "" ]
then
	ardourx
else
	if [ "`ps -A | grep 'qjackctl'`" != "" ]
	then
		$COMMAND --title "Ardour launcher" --yesno "Please use the other window to configure and start the JACK Audio Connection Kit.  Then choose OK/Yes to start ardour." 0 0 && ardourx
	else
		qjackctl&
		sleep 1
		$COMMAND --title "Ardour launcher" --yesno "Please use the other window to configure and start the JACK Audio Connection Kit.  Then choose OK/Yes to start ardour." 0 0 && ardourx
	fi
fi
