+ else
+ # gnome-terminal doesn't set WINDOWID currently; we can try to work around this.
+ false
+#hmmm: so far, none of these approaches are any good.
+# # not good solution; gets wrong titles. plus uses xdotool which is not installed by default in ubuntu.
+# if [[ ! -z "$(which xdotool)" ]]; then
+# term_title_found="$(xprop -id $(xdotool getactivewindow) | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
+# fi
+# # this solution also fails by getting the wrong window title if this one isn't focussed.
+# if [[ ! -z "$(which xwininfo)" ]]; then
+# term_title_found=$(xwininfo -id $(xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }') | awk -F\" '/xwininfo:/ { print $2; exit }')
+# fi
+ fi
+ fi
+ echo -n "$term_title_found"
+}
+
+# reads the current terminal title, if possible, and saves it to our record.
+function save_terminal_title()
+{
+ local title="$(get_terminal_title)"
+ if [ "$title" != "unknown" ]; then
+ # there was a title, so save it.
+ if [ ! -z "$DEBUG_TERM_TITLE" ]; then
+ echo "saving prior terminal title as '$title'"
+ fi
+ export PRIOR_TERMINAL_TITLE="$title"
+ else
+ # the terminal had no title, or we couldn't access it, or there's no terminal.
+ if [ ! -z "$DEBUG_TERM_TITLE" ]; then
+ echo "not saving prior terminal title which was empty"