[comp.windows.open-look] xterm titles in olwm

jfd@octel.UUCP (John F. Detke) (04/19/91)

I can't for the life of me get control sequences to alter the title of my
xterms. I have RTFM, and the FAQ in comp.windows.x, but neither of those methods
work. Any clues as to what I am doing wrong? If it matters, Sparc SunOS 4.1,
openwindows 2.0.

Thanks,  
jfd

-- 
John F. Detke
Octel Communications Corp
890 Tasman Drive
M/S 05-04
Milpitas CA 95035
jfd@octel.com

fcaggian@kepler.com (Frank Caggiano) (04/20/91)

The following escape sequenses set the title strips fine for both xterm's
and cmdtool/shelltool windows in 2.0.  I Used /usr/5bin/echo so that I 
could use \033 for the escape code rather then putting an actual escape 
in the file. (an actual escape caused the cmdtool windows to lock up if
you cat'ed out the file.

Hope This helps.

if ( $TERM == "sun-cmd" ) then 
	# set initial strip to cwd
	/usr/5bin/echo  '\033]l'$HOST' - Dir(s): '`dirs -l` '\033\\\c'
	
	#Make cd set window header
	alias cd 'cd \!*; /usr/5bin/echo '\033]l${HOST}: '`dirs` '\033\\\c''

	#make wu put update into header
	alias wu '/usr/5bin/echo  "\033]l `uptime` \033\\\c"'  

	alias pushd 'pushd \!*; /usr/5bin/echo  '\033]l${HOST}: '`dirs` '\033\\\c''
	alias popd  'popd \!*;  /usr/5bin/echo  '\033]l${HOST}: '`dirs` '\033\\\c''
	alias sd    'pushd; /usr/5bin/echo  '\033]l${HOST}: '`dirs`' \033\\\c''


else if ( $TERM == "xterm" )  then

	# set initial strip to cwd
	/usr/5bin/echo  '\033]2;'$HOST' -  Dir(s): '`dirs -l`' \007\c'

	#Make cd set strips and icon
	alias cd 'cd \!*; /usr/5bin/echo  "\033]2;${HOST}: `dirs` \007\c"'

	alias wu '/usr/5bin/echo  "\033]2;`uptime`\007\c"'

	alias pushd 'pushd \!*; /usr/5bin/echo  "\033]2;${HOST}: `dirs` \007\c"'
	alias popd  'popd \!*; 	/usr/5bin/echo  "\033]2;${HOST}: `dirs` \007\c"'
	alias sd    'pushd;  	/usr/5bin/echo  "\033]2;${HOST}: `dirs` \007\c"'
endif
-- 
Frank Caggiano                      INTERNET: fcaggian@kepler.com  
Kepler Financial Management, Ltd.       UUCP: ..!uunet!kepler1!fcaggian
100 North Country Rd.                    fax: (516) 751-8678
Sekauket, NY 11733                     voice: (516) 689-6300 

Stuart.Marks@Eng.Sun.COM (Stuart Marks) (04/23/91)

    I can't for the life of me get control sequences to alter the title of
    my xterms.  I have RTFM, and the FAQ in comp.windows.x, but neither of
    those methods work.  Any clues as to what I am doing wrong?  If it
    matters, Sparc SunOS 4.1, openwindows 2.0.

Well, it could be that the FM is out of date. :-)

Here are the escape sequences I use.  Note that \e is escape, ^G is
control-G, and "..." is the text of the label.

	\e]0;...^G		sets both icon and window
	\e]1;...^G		sets icon label
	\e]2;...^G		sets window title

Previous versions of xterm accepted anything other than ^G to terminate
the string.  Starting with X11R4 (I believe) xterm became more
restrictive, and requires that the string be terminated with a ^G.  The
xterm with OpenWindows 2.0 is pretty much identical to the X11R4 xterm.

s'marks

Stuart W. Marks			ARPA: smarks@eng.sun.com
Windows & Graphics Software	UUCP: sun!smarks
Sun Microsystems, Inc.

jc@raven.bu.edu (James Cameron) (04/23/91)

>>>>> On 19 Apr 91 01:21:20 GMT, jfd@octel.UUCP (John F. Detke) said:

jfd> I can't for the life of me get control sequences to alter the title of my
jfd> xterms. I have RTFM, and the FAQ in comp.windows.x, but neither of those methods
jfd> work. Any clues as to what I am doing wrong? If it matters, Sparc SunOS 4.1,
jfd> openwindows 2.0.

jfd> Thanks,  
jfd> jfd


The following alias (for csh && tcsh) changes the title of the xterm
to the current directory:

if ($?TERM && $TERM == 'xterm') then 
  alias cd 'cd \!*;xtitle "  " $HOST": "$cwd"  "'
endif

Now, save the appended program as xtitle.c somewhere in your
path, and compile it as follows:

$ cc -o xtitle xtitle.c

You can also just do a

$ xtitle Whatever-your-heart-desires

to change it as well.

Hope it helps!

jc
					-- James Cameron  (jc@raven.bu.edu)

Signal Processing and Interpretation Lab.  Boston, Mass  (617) 353-2879
------------------------------------------------------------------------------
"But to risk we must, for the greatest hazard in life is to risk nothing.  For
the man or woman who risks nothing, has nothing, does nothing, is nothing."
	(Quote from the eulogy for the late Christa McAuliffe.)





--  Remove everything above and including this line and save to xtitle.c --
#include <stdio.h>

/* 
* This program takes the input string and puts it into the 
* the xterm title.  If you change the value of the first 
* number in the printf statement, you can determine where
* the string will go.  You can use either 0, 1, or 2.  0
* puts it in the title of the xterm; 1 puts it into the
* the icon name, and 2 does both.
*/ 


main(argc, argv)
int argc; char *argv[];
{
	char buff[512];

	argv++; argc--;
	buff[0] = '\0';
	while (argc--) {
		strcat( buff, *argv++ );
		strcat( buff, " " );
	}
	buff[strlen(buff)-1] = '\0';
	printf( "%c]0;%s%c", (char)27, buff, (char)7 ); fflush(stdout);
}