#!/bin/sh -
PATH=/bin:/usr/bin; export PATH

# xtitle - set titlebar, label and icon strings for an X11 terminal window
# Steve Kinzler, kinzler@cs.indiana.edu, Nov 93
# http://www.cs.indiana.edu/hyplan/kinzler/home.html#x11

dflttarg=tli
target=; bad=

while :
do
	case $# in
	0)	break;;
	*)	case "$1" in
		-[tli]*)	target="$target$1";;

		--)		shift; break;;
		-h)		bad=t; break;;
		-*)		bad=t; echo "$0: unknown option ($1)" 1>&2;;
		*)		break;;
		esac
		shift;;
	esac
done

case "$#,$bad" in
0,*|*,?*)	cat << EOF 1>&2
usage: $0 [ -tli ] title ...
	-t	set titlebar string
	-l	set label string
	-i	set icon string
	default sets all three to the given title
EOF
		exit 1;;
esac

case "$target" in
'')	target=$dflttarg;;
esac

case "$target" in
*t*)	echo "]2;$*\c";;
esac
case "$target" in
*l*)	echo "]1;$*\c";;
esac
case "$target" in
*i*)	echo "]I;$*\c";;
esac
