#!/bin/sh - ME=`basename "$0"` WANT_DOMAIN=false Usage() { echo "Usage: $ME [title [icon-title]]" >&2 echo 'If only "title" is specified, it will also set the icon title.' >&2 echo 'If neither is specified, both will be set to the hostname.' >&2 exit 0 } if [ $# -gt 2 ]; then Usage fi if [ $# -lt 1 ]; then WINTITLE=`hostname` if $WANT_DOMAIN; then if expr "$WINTITLE" : '[^.]*$' > /dev/null; then WINTITLE=`nslookup "$WINTITLE" \ | grep '^Name:' \ | head -1 \ | sed 's/^Name:[ ]*//'` fi else WINTITLE=`expr "$WINTITLE" : '\([^.]*\)'` fi else WINTITLE="$1" fi if [ $# -lt 2 ]; then ICONTITLE="$WINTITLE" else ICONTITLE="$2" fi printf "\033]2;$WINTITLE\a\033]1;$ICONTITLE\a" #--