Subject: FVWM: Dynamic Xterm title fix

From: Jonathan Watson <[email-masked]>
Date: Tue, 18 Jun 1996 11:23:25 -0400 (EDT)

I have been using the cwdcmd feature in tcsh to dynamically change the 
titles of my xterms. Currently I have X setup so that I have a 
"controller" xterm....To quit X I exit/kill/destroy this particular Xterm 
and the window manager/X/apps go down. 
In my .xsession I label the "controller" xterm CONTROLLER, but when my .cshrc 
executes, cwdcmd overrides the title set in my .xsession with the -title 
switch and changes the name of the xterm. I have tried inserting a -e 
switch in the xterm call so that I could execute a special script or set 
an enviornment variable to identify the controller xterm or change the 
cwdcmd alias for that xterm, but it didn't work. I have 2 major problems.

1. Any attempt to set an enviornment variable from the -e fails. (ie. setenv 
CONTROLLER 1). 
2. The .cshrc and shell setup scripts execute AFTER whatever I specify in 
the xterm call with the -e switch.

	From these observations an various experiments I thought that if 
I could read the title of the xterm within my .cshrc and use it (the 
title) in an if statement I could then have the cwdcmd changed for that 
specific xterm.

SO, my question is:
	How do you get the title of an xterm from within a shell script??

Any other solutions to this problem??

	TIA,
		Jonathan Watson

*-------------------------------------------*-------------------------------*
| The MITRE Corporation			    | Northeastern University       |
| D086 Advanced Systems - Signal Processing | Boston,  Mass., USA.	    |
| Bedford, Mass., USA.		  	    | College of Engineering (EE)   |
|        [email-masked]	 	    |    [email-masked]  |
*-------------------------------------------*-------------------------------*

--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: [email-masked] (Emilio Lopes)
Date: Tue, 18 Jun 96 12:51 EST

>>>>> "JW" == Jonathan Watson <[email-masked]> wrote:

JW> 	How do you get the title of an xterm from within a shell script??

echo -en "\033]2;Xterm - ${LOGNAME}@${HOST}:${PWD}\007"

Works for Bash builtin echo.

Emilio.

-- 
 Emilio C. Lopes <mailto:[email-masked]>
 FINPE, Instituto de Fisica      E-mail: [email-masked]
 Universidade de Sao Paulo       Phone : (+55 11) 818-6724 (Voice)
 Caixa Postal 66318                      (+55 11) 818-6715 (Fax)
 05389-970  Sao Paulo - SP
 BRAZIL
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Chris Taylor <[email-masked]>
Date: Tue, 18 Jun 1996 16:55:54 -0400 (EDT)

> title) in an if statement I could then have the cwdcmd changed for that 

This is more a shell/X problem than an fvwm problem.

I'm not familiar with tcsh, but cwdcmd sounds similar to the precmd() function
in Z Shell. Mine looks like this:

    precmd () {
            print -Pn "^[]0;${XTERMNAME}%M   %l   %5.^G"
    }

This yields a string in the titlebars and icons of my xterms that looks like
"belldandy   p1   ~" (hostname, tty, current directory).

The XTERMNAME variable is the trick here. Normally it's unset. For my console
xterm (I have a setup like Jon's for session control), I use this in my
.xsession:

    XTERMNAME="CONSOLE: " xterm +ut -C -fn 5x8

Then my titlebar looks like "CONSOLE: belldandy   p1   ~". Since I set the
variable right before I run the xterm, it doesn't get propagated to subshells.
I can also use it for other kinds of xterms, if needed.

I don't know how you'd do this in tcsh. The % macros used in zsh's print
command won't be the same, but the use of XTERMNAME should be similar.

Chris Taylor     / My views do not represent \ PGP public key available
[email-masked] \    those of Cabletron.    / via keyserver or request

---

From: [email-masked] (Emilio Lopes)
Date: Tue, 18 Jun 96 20:46 EST

>>>>> "CT" == Chris Taylor <[email-masked]> wrote:

CT> I don't know how you'd do this in tcsh. The % macros used in zsh's print
CT> command won't be the same, but the use of XTERMNAME should be similar.

There is an explicit example in the tcsh man page. People interested
can search for the string "cwdcmd".

---

From: Ron Kellam <[email-masked]>
Date: Wed, 19 Jun 1996 09:47:13 +1000 (EST)

Thus spake Jonathan Watson <[email-masked]>
> Any other solutions to this problem??

Under ksh I set an env var to lock my console xterm and stop its title getting
changed to the current path - here's some snippets:

I have a script called console with the following line in it:

  LOCK_TITLE=1 xterm -C -bg SteelBlue -n Console -T Console

In the line above, the xterm gets spawned with LOCK_TITLE set to 1.  The value
of this var is then checked in the function that sets the xterm title - if
LOCK_TITLE is set, the xterm title doesn't get updated when a dir change
occurs.

Elsewhere is the ksh function:

  function term_title
  {
    if (( ${LOCK_TITLE:=0} == 0 )); then
      label_window $*
      label_icon $*
    fi
  }

Everytime pwd changes, some higher function gets invoked to mash the hostname
and path, and then term_title is called to set the title/icon.

Hopes this help.

Cheers,

Ron

--

Ron Kellam ([email-masked])
Australian Telecom Operation
Hewlett Packard Australia
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: [email-masked] (Albrecht Kadlec)
Date: Wed, 19 Jun 96 11:57:51 +0200

>>>>> Jonathan Watson writes:

J> I have been using the cwdcmd feature in tcsh to dynamically change the 
J> titles of my xterms. Currently I have X setup so that I have a 
using the prompt is much faster than using the cwdcmd alias, since the
alias has to execute external commands (the version with the variables did
never work), and the prompt syntax has a %? specification for almost
everything:

I use this in my .cshrc:
if ($?tcsh == 0) exit
...
if ($term == xterm) then
#       alias cwdcmd 'echo "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'
        set prompt="%{\e]2\;%m:%B%~%b^g\e]1\;%m^g\r%}%T %B%m:%~%#%b "
else

J> "controller" xterm....To quit X I exit/kill/destroy this particular Xterm 
J> and the window manager/X/apps go down. 
J> In my .xsession I label the "controller" xterm CONTROLLER, but when my .cshrc 
J> executes, cwdcmd overrides the title set in my .xsession with the -title 
J> switch and changes the name of the xterm. I have tried inserting a -e 
J> switch in the xterm call so that I could execute a special script or set 
J> an enviornment variable to identify the controller xterm or change the 
J> cwdcmd alias for that xterm, but it didn't work. I have 2 major problems.

J> 1. Any attempt to set an enviornment variable from the -e fails. (ie. setenv 
J> CONTROLLER 1). 
guess so. you could only do an xterm -e tcsh -c script
and have a setenv in the script

or use -l (? - our manual pages on tcsh are not up-to-date).

J> 2. The .cshrc and shell setup scripts execute AFTER whatever I specify in 
J> the xterm call with the -e switch.
hint: the .login comes after .cshrc

J> 	From these observations an various experiments I thought that if 
J> I could read the title of the xterm within my .cshrc and use it (the 
J> title) in an if statement I could then have the cwdcmd changed for that 
J> specific xterm.

J> SO, my question is:
J> 	How do you get the title of an xterm from within a shell script??
don't think this is possible.

J> Any other solutions to this problem??

I do sth similar:
I have a CONSOLE ( -C  switch) xterm whih is 70x4 and swallowed into my
buttonbar which in term is sticky. (So I can always start any program and
see any Console Messages. Also, since it's the first xterm which is
started, all write & talk messages go there.)

My prompt normally looks like "time hostname:path>" But since that xterm is
rather small and I know which machine I'm on (physically), I set my prompt
just to time path> in my .login. Since the console is the only xterm which
is started with -ls, and .login is executed after .cshrc, the former
overwrites the latter.

so in short: I do my usual setup in .cshrc, my console is 

*FvwmButtons(10x2, Swallow (UseOld, NoClose, Respawn) "Console" \
"Exec xterm -name Console -ls -C -display $HOSTDISPLAY -geometry 70x5-1500-1500")

and my .login contains:

unset visiblebell		# Console is the only xterm that may beep
set watch=(1 any any)		# keep track of logins
set prompt="%T %B%~%#%b "	# short prompt

hope this helps.
albrecht
-- 
Peace on earth and mercy mild, Mother Brown has lost her child
 - Just another Forgotten Son				-- Marillion
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].