2014-03-02 16:06:45 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Try to run a command in an appropriate type of terminal window
|
|
|
|
# depending on whats available
|
|
|
|
# Sigh: theres no common way of handling command line args :-(
|
2014-03-10 19:37:02 -03:00
|
|
|
name="$1"
|
|
|
|
shift
|
2016-09-18 23:55:42 -03:00
|
|
|
echo "RiTW: Starting $name : $*"
|
2014-03-10 19:37:02 -03:00
|
|
|
# default to xterm as it has the most consistent options and can start minimised
|
2016-06-23 12:27:28 -03:00
|
|
|
if [ -n "$DISPLAY" -a -n "$(which osascript)" ]; then
|
|
|
|
osascript -e 'tell application "Terminal" to do script "'"$* "'"'
|
|
|
|
elif [ -n "$DISPLAY" -a -n "$(which xterm)" ]; then
|
2016-05-16 04:23:09 -03:00
|
|
|
xterm -iconic -xrm 'XTerm*selectToClipboard: true' -xrm 'XTerm*initialFont: 6' -n "$name" -name "$name" -T "$name" -hold -e $* &
|
|
|
|
elif [ -n "$DISPLAY" -a -n "$(which konsole)" ]; then
|
|
|
|
konsole --hold -e $*
|
|
|
|
elif [ -n "$DISPLAY" -a -n "$(which gnome-terminal)" ]; then
|
|
|
|
gnome-terminal -e "$*"
|
2015-01-20 15:51:19 -04:00
|
|
|
elif [ -n "$STY" ]; then
|
|
|
|
# We are running inside of screen, try to start it there
|
2016-05-16 04:23:09 -03:00
|
|
|
screen -X screen -t "$name" $*
|
2014-03-10 19:37:02 -03:00
|
|
|
else
|
2015-01-20 15:51:19 -04:00
|
|
|
filename="/tmp/$name.log"
|
2016-09-18 23:55:42 -03:00
|
|
|
echo "RiTW: Window access not found, logging to $filename"
|
2015-01-20 15:51:19 -04:00
|
|
|
cmd="$1"
|
|
|
|
shift
|
2015-12-10 23:06:13 -04:00
|
|
|
# the following "true" is to avoid bash optimising the following call
|
|
|
|
# to avoid creating a subshell. We need that subshell, or
|
|
|
|
# _fdm_input_step sees ArduPilot has no parent and kills ArduPilot!
|
2016-05-16 04:23:09 -03:00
|
|
|
( : ; $cmd $* &>"$filename" < /dev/null ) &
|
2014-03-10 19:37:02 -03:00
|
|
|
fi
|
2014-03-02 16:06:45 -04:00
|
|
|
exit 0
|