[techtalk] Prog name in Titlebar

Telsa Gwynne hobbit at aloss.ukuu.org.uk
Mon Feb 21 20:32:40 EST 2000


On Mon, Feb 21, 2000 at 08:19:22AM -0500 or thereabouts, Phil Savoie wrote:
> Would anyone happen to know how to include the prog name in the title
> bar  of a kde session terminal?  Basically what I would like to do is
> start the prog and instead of "Konsole" in the titlebar have the prog
> name displayed.
> Thanks in Advance

I thought someone would have replied to this already, but I'll have
a go:

I don't know the KDE stuff at all well, but if the terminal emulator
is vaguely xterm-compliant, you'll want the xterm control codes. I
found them from the XFree86-doc rpm on Red Hat (they end up in
/usr/doc/XFree86-doc-(versionnumber)/xterm/ctlseqs.PS.gz there).
When you read them you'll realise when they're a PS rather than 
straight ASCII. Lots of things that representing in ASCII would
be a pest.

To get the control codes to work in bash (again, your shell may
vary), you use ^V before typing the control code in question.

Initially I would just type
	echo "^V^[2;1 blah blah blah" (or whatever it is, I forget the
control code now!) to get the terminal I typed it into to be called 
blah blah blah.

I got bored of typos, learnt about how to get control codes into 
shellscripts, and made a shellscript called titlebar.sh (I'm so
original..) which goes:

#!/bin/sh

# How to make your xterm, gnome-terminal, etc, have a new title if
# you didn't start it with xterm --title or gnome-terminal --title.
#
# $* is "whatever you typed as an argument when you ran the script"
# So './titlebar.sh Horace' gives you a window called Horace.

printf "\033]0;$*\007"
echo "Changed window title to $*"

You could try your luck with that, but of course you'll have to
remember to do it before starting the program up. I do this a lot
because I roll my windows up into the titlebar a lot for space
reasons. 

If you want things to occur automatically and are using bash, you
could look at the Bash-Prompt-HOWTO. Section 4 in it (in my out
of date copy) is called Xterm Title Bar Manipulations. If it's
not on your system, head for your favourite LDP (www.linuxdoc.org)
mirror, because I'm sure I saw it there recently. Essentially, 
you use your prompt, which of course is regularly printed; and
include in your prompt stuff that will affect the title bar. It
should give you some ideas, at least.

All this, as I say, will rely on how well the terminal itself
emulates xterm, but I think the titlebar ones are something that
most terminals do. 

Hope this helps.

Telsa

************
techtalk at linuxchix.org   http://www.linuxchix.org




More information about the Techtalk mailing list