wicinski@nrl-cmf.UUCP (Tim Wicinski) (03/29/89)
a few releases of twm ago, Tom sent out a small program called 'mytitle' to the twm release. It didn't do much, but added enough to each xterm so when I iconified it, the machine name would appear. I'm sure it went against all specs, etc. but does anyone still have this code, or can point me as how to manage this myself? (not that i have time, but...) thanks tim
jim@EXPO.LCS.MIT.EDU (Jim Fulton) (03/29/89)
If you are trying to set the title string from xterm, you can send the following escape sequences: To set the title string: <ESC> ] 2 <space> new-title-string <non-printing-character> To set the icon name: <ESC> ] 1 <space> new-icon-string <non-printing-character> The new strings may have any printable characters (including spaces). They are terminated by any non-printing character. The version of "cd" I use puts the current directory into the title as follows (I use echo -n and ^G so that I don't get any extra characters; if you don't mind a blank line, you can just use echo without the ^G). You'll have to replace the ^[ and ^G with octal 033 and 007, respectively. alias cd 'chdir \!*;echo -n "^[]2 ${cwd}^G"'
toml@hpfcdq.HP.COM (Tom LaStrange) (03/29/89)
>a few releases of twm ago, Tom sent out a small program called 'mytitle' >to the twm release. It didn't do much, but added enough to each xterm so >when I iconified it, the machine name would appear. I'm sure it went >against all specs, etc. but does anyone still have this code, or can >point me as how to manage this myself? (not that i have time, but...) > Here it is. -- Tom LaStrange Hewlett Packard Co. ARPA: toml%hpfcla@hplabs.hp.com Graphics Technology Division UUCP: hplabs!hpfcla!toml Fort Collins, CO --------------------------------------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Tom LaStrange <toml@hpfcdq> on Wed Mar 29 07:25:13 1989 # # This archive contains: # mytitle.c # LANG=""; export LANG echo x - mytitle.c cat >mytitle.c <<'@EOF' #include <stdio.h> main() { char *wd, *home, *term, dir[200], host[100]; int i, len; if ((wd = (char *)getcwd(NULL,200)) == NULL) exit(0); term = (char *)getenv("TERM"); if (strncmp(term, "xterm", 5) && strncmp(term, "vt100", 5)) exit(0); home = (char *)getenv("HOME"); /* printf("term = \"%s\" wd = \"%s\" home = \"%s\"\n", term, wd, home);*/ gethostname(host,100); len = strlen(home); for (i = 0; i < len; i++) { if (home[i] != wd[i]) break; } if (i == len) printf("\033]2;%s: ~%s\007", host,&wd[i]); else printf("\033]2;%s: %s\007", host,wd); printf("\033]1;%s\007", host); /* printf("\033]0;%s\007", host); */ exit(0); } @EOF chmod 644 mytitle.c exit 0
tom@ICASE.EDU (Tom Crockett) (03/30/89)
> *Excerpts from xpert: 28-Mar-89 twm program 'mytitle' Tim* > *Wicinski@CMF.NRL.NAV (367)* > a few releases of twm ago, Tom sent out a small program called 'mytitle' > to > the twm release. It didn't do much, but added enough to each xterm so > when > I iconified it, the machine name would appear. Shouldn't the same effect be achievable using an xterm escape sequence? I'm using that capability with awm to redefine the "cd" command so that it causes the window and icon titles to follow the current working directory. The aliases I use to do this look like alias xheader 'echo -n "^[]2;\!*^G"' # sets window title alias xiheader 'echo -n "^[]1;\!*^G"' # sets icon label alias cd 'cd \!* ; xheader "${Host}:${cwd}"; xiheader ${Host}:`basename $cwd`' Note: "^[" and "^G" must be the single control characters ESC and ctrl-G. The character strings "^[" and "^G" don't hack it. There is a bug in awm when the "icon.labels" resource is turned on, which prevents the icon label from being updated when it changes (it sticks with the icon name in use when the window was first iconified). However, with the uwm-style icons, the above escape sequences work fine. I haven't tried any of this with twm, but this is a really handy feature. It merely requires that the window manager pay attention to the current values of the window and icon titles. (Presumably xterm is sending some kind of an event to the window manager?) Tom Crockett ICASE Institute for Computer Applications in Science and Engineering M.S. 132C e-mail: tom@icase.edu NASA Langley Research Center phone: (804) 864-2182 Hampton, VA 23665