Subject: FVWM: Window title for xterm

From: Rasmus Peter Tamstorf <[email-masked]>
Date: Thu, 16 May 1996 17:00:16 +0200 (METDST)

This question may not belong to this list, but anyway ...

Is it possible to change the title/iconname of a xterm-window dynamically 
to show the name of the process running in the foreground if such one exists 
or if such one does not exist the current directory ?

I am using the taskbar in fvwm2, but it looses some of its value when you 
have 5 icons all named 'xterm'. It would be really nice if you could see 
what was running in those xterms.

  Rasmus

------------------------------------------------------------------------------
Rasmus Tamstorf                                 "A problem worth attacking    
Institute of Mathematical Modelling              always strikes back"    
Technical University of Denmark                                 
E-mail : [email-masked]                                    (Unknown, to me ;-)
------------------------------------------------------------------------------

--
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: Alan Wild <[email-masked]>
Date: Thu, 16 May 1996 13:40:14 -0400 (EDT)

> or if such one does not exist the current directory ?

This is what I use to change the xterm title to include my current host
and directory.  The iconname has also been changed to reflect the host.
BTW, this is all for bash.  You set your prompt to this string and then
each time your prompt changes, the title/iconname is updated:

	PS1="\[\033]0;\h:\w\007\033]1;\h\007\]\h\$ "

The \033 implies an ESC character. The \007 implies a ^G.

-Alan

-- 
Alan Wild                            [email-masked]       
f/s/c lou95                      http://www.spd.louisville.edu/~triangle/
IT-HSC Consultant                 http://www.spd.louisville.edu/~arwild01
--
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: Todd Tyrone Fries <[email-masked]>
Date: Thu, 16 May 1996 13:29:42 -0600 (MDT)

> The \033 implies an ESC character. The \007 implies a ^G.

This wouldn't be so bad, except it redraws the entire line everytime you type
a character.  Not too bad on localhost, but very slow over a modem ...

Anyone ever figure out how to keep the redraw from occurring?

My solution was to do this:

PS1='\h\w:\$ '
if [ "$TERM" = "xterm" ]; then
  function cd ()
  {
    builtin cd $*
    xtitle "${HOSTNAME%%.*}:$PWD `cat /etc/ip` (`date`)"
  }
  else
  function cd ()
  {
    builtin cd $*
  }
fi
xtitle=()
{
    echo -e -n "\033]2;$*\007"
}

(also for bash)
-- 
Todd Fries

---

From: Alan Wild <[email-masked]>
Date: Thu, 16 May 1996 15:40:03 -0400 (EDT)

> My solution was to do this:

Well. . . .since you mentioned it, I actually do this:

	if [ "${TERM}" = "xterm" ]; then
		if [ "${GROUP:-}" != "" ]; then
			PS1="\[\033]0;\h:${GROUP}:\w\007\033]1;\h\007\]\h\$ "
		else
			PS1="\[\033]0;\h:\w\007\033]1;\h\007\]\h\$ "
		fi
	else
		if [ -n "${GROUP:-}" ]; then
			PS1="${GROUP}\h:\w\$ "
		else
			PS1="\h:\w\$ "
		fi
	fi

BUT, he wasn't asking about all the nitty-gritty details.

-Alan

---

From: Ron Kellam <[email-masked]>
Date: Fri, 17 May 1996 08:16:42 +1000 (EST)

Thus spake Rasmus Peter Tamstorf <[email-masked]>
> what was running in those xterms.

Below is a snippet from a TCL script I use to set the title of each new xterm I
create.  The key is the ESC sequences...

------------

proc setXTermTitle {title} {
  # Set title of the XTERM
  puts -nonewline "\033]2;$title\007";
  # Set ICON label of XTERM
  puts -nonewline "\033]1;$title\007";
}

------------

Cheers,

Ron

------------------------------------------------------------------------
Ron Kellam                        | Phone: +613 9210 5553
Hewlett Packard Australia         | Fax:   +613 9210 5550         .-_!\
Australian Telecom Operation      | Email: [email-masked] / ATO \
347 Burwood Highway, Burwood East |                              \_.-._/
Victoria, Australia, 3151         | "I speak for myself..."           v
------------------------------------------------------------------------
         "Even if you're on the right track, you still get
               run over if you don't keep moving"
------------------------------------------------------------------------
--
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: Rasmus Peter Tamstorf <[email-masked]>
Date: Fri, 17 May 1996 11:47:00 +0200 (METDST)

> Todd Tyrone Fries wrote:
[---trim---]
> BUT, he wasn't asking about all the nitty-gritty details.

True, *BUT* I was hoping for even more ;-) Suppose I have an xterm in 
which I start top, gdb or something like that. Has anyone found out how 
I can make the window title reflect that ? In pseudo-code I'd like 
something like :

  set prg = program running in the foreground
  if (prg = shell) then
    title = cwd
  else
    title = prg
  endif

Rasmus

---

From: "Matthew N. Dodd" <[email-masked]>
Date: Fri, 17 May 1996 05:23:26 -0500 (CDT)

> I can make the window title reflect that ? In pseudo-code I'd like 

Well, you could just write wrappers for all the commands you run...
Probably something that knows how to parse argv[0] so you could just
make a generic wrapper.  This is an ugly solution.

I think a better solution would be to add something to your shell
that would allow you to run some command before the fork/exec
of your input.  tcsh has the `precmd` which is sort of what we want
but backwards.  I use it to set the xterm title to the current working
directory and the hostname.  `precmd` is executed before the prompt
is displayed.  What we need is a sort of `postcmd` that is executed 
AFTER you press enter on the CL.

And for our next silly project we can use the graphics features in
rxvt to create icons in our windows. *gag*

Have a good one.

| Matthew N. Dodd   | [email-masked]    | http://www.jurai.net/~winter    |
| Technical Manager | [email-masked] | http://www.intersurf.net        |
| InterSurf Online  | "Welcome to the net Sir, would you like a handbasket?"|