Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 1998 10:23:32 -0800 (PST)
From:      David Wolfskill <dhw@whistle.com>
To:        freebsd-questions@FreeBSD.ORG, robert@namodn.com
Subject:   Re: xterm title/name
Message-ID:  <199812111823.KAA19076@pau-amma.whistle.com>
In-Reply-To: <Pine.BSF.3.96.981203190413.29511A-100000@namodn.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>Date: Thu, 3 Dec 1998 19:07:34 +0000 (GMT)
>From: Robert <robert@namodn.com>

>Is there a way to change the title and name of a running xterm from the
>commandline? 

Sure.

>( I don't know a whole lot about how X programs are managed, but I want a
>way to change the titlebar and iconified name of an xterm when certain
>events happen; it would also be useful to change the iconified graphic )

>Even if I have to learn some wacky scripting language, that's ok too if
>someone can point me in the right direction )

Below my .sig is a shar of a script I cobbled up for one of my
colleagues to do it....

david
-- 
David Wolfskill		UNIX System Administrator
dhw@whistle.com		voice: (650) 577-7158	pager: (650) 371-4621

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	xtt
#
echo x - xtt
sed 's/^X//' >xtt << 'END-of-xtt'
X#!/usr/local/bin/perl
X
X#	Set window and/or icon title for xterms
X
X#	David Wolfskill; Whistle Communications
X#	$Id: xtt,v 1.2 1998-10-07 12:48:09-07 dhw Exp $
X
X#	This script is arguably rather braindead; it uses the table
X#	of xterm "escape sequences" from the O'Reilly _X Window System
X#	User's Guide_, X11R5 version, p. 764.
X
Xuse File::Basename;
Xuse Getopt::Long;
X
X$Getopt::Long::ignorecase = 0;
X
Xmy(%optctl) = ( both => \$b_text,
X                help => \$help_req,
X                name => \$n_text,
X                title => \$t_text,
X		Test => \$test_mode );
X
Xmy($result) = &GetOptions(\%optctl, "both:s", "help", "name:s",
X  "title:s", "Test");
X#	Command-line options:
X#	both:  Text is for both title & name
X#	help:  if specified, a usage message is issued & the script exits.
X#	name:  Text is for name only
X#	title: Text is for title only
X#	Test:  if specified, only mention what would have been done (test mode)
X
Xif (!($b_text || $n_text || $t_text)) {
X  $b_text = join(' ', @ARGV);
X  $help_req = 1 if (!$b_text);
X}
X
Xif ($help_req) {
X  my($me) = basename("$0");
X  print "Usage:\t$me [-both \"Title and name text\"] [-name \"Name text\"]\n";
X  print "\t\t[-title \"Title text\"] [-help] [-Test]\n";
X  print "  or\n\t$me \"Title and name text\"\n";
X  print "\nThe option names may be abbreviated; they are case-sensitive.\n";
X  print "As shown, if you want to change both the name and the title,\n";
X  print "  you don't need to specify an option name.\n";
X  print "Please note that some window managers may not actually use both values.\n";
X  exit 0;
X}
X
Xmy($string) = "";
X
X$string .= &append("0", "$b_text") if ("$b_text");
X$string .= &append("1", "$n_text") if ("$n_text");
X$string .= &append("2", "$t_text") if ("$t_text");
X
Xif ($test_mode) {
X  $string =~ s/\e/<ESC>/g;
X  $string =~ s/\a/<BEL>/g;
X  $string .= "\n";
X}
X
Xprint "$string";
X
Xexit 0;
X
Xsub append {
X#  Given the cryptic xterm code & the text, return an appropriate xterm
X#  escape sequence.
X
X  my($code) = shift;
X  my($text) = shift;
X  warn "Using the BEL character within the text is hazardous\n"
X    if ($text =~ /\a/);
X  return("\e]${code};${text}\a");
X}
END-of-xtt
exit


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812111823.KAA19076>