File: xtitle.sh

package info (click to toggle)
xtitle 1.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116 kB
  • sloc: sh: 88; makefile: 59
file content (93 lines) | stat: -rwxr-xr-x 2,523 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh -
PATH=/bin:/usr/bin; export PATH

# xtitle - set window title and icon name for an X11 terminal window
# Steve Kinzler, kinzler@cs.indiana.edu, Nov 93/Nov 98/Mar 00/Dec 09
# see website http://www.cs.indiana.edu/~kinzler/xtitle/
# http://www.cs.indiana.edu/~kinzler/home.html#x11

# An older version of this script (not recommended for use in dtterm's)
# is packaged for Solaris and available at
#	http://metalab.unc.edu/pub/solaris/sparc/

#   Copyright
#
#	Copyright (C) 1993 Stephen B Kinzler <kinzler@cs.indiana.edu>
#
#   License
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program. If not, see <http://www.gnu.org/licenses/>.

#version=1.0.0
#version=1.0.1	# 2009-12-10: add copyright/GPL notice for debian pkg
#version=1.0.2	# 2009-12-18: add -V option, long options
#version=1.0.3	# 2014-03-19: add xtctl supplementary program
version=1.0.4	# 2014-11-26: update FSF address

dflttarg=ti
target=; bad=

while :
do
	case $# in
	0)	break;;
	*)	case "$1" in
		-[tiqV]*)	target="${target}$1";;
		--title)	target="${target}-t";;
		--icon)		target="${target}-i";;
		--quiet)	target="${target}-q";;
		--version)	target="${target}-V";;

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

case "$target" in
*V*)	echo "$version"; exit 0;;
esac

case "$#,$bad" in
0,*|*,?*)	cat << EOF 1>&2
usage: $0 [ -tiq ] string ... | -V
	-t, --title	set window title
	-i, --icon	set icon name
	-q, --quiet	quiet mode, don't report settings
	-V, --version	only output program version
Without -t or -i options, both the window title and icon name are set.
Version $version
EOF
		exit 1;;
esac

case "$target" in
''|-q)	target="$target$dflttarg";;
esac

case "$target" in
*t*)	case "$target" in
	*q*)	echo "]2;$*" | tr -d '\012';;
	*)	echo "]2;$*title = $*";;
	esac;;
esac
case "$target" in
*i*)	case "$target" in
	*q*)	echo "]1;$*" | tr -d '\012';;
	*)	echo "]1;$*icon  = $*";;
	esac;;
esac