xdeco - output xterm titlebar & iconname control sequences
xdeco -t title -i icon xdeco -t %h%d%m%p -i %d xdeco -n ...
Outputs xterm control sequences to set window title & icon name.
With -n, the window title or icon name are output alone (ie no control characters).
Title & icon arguments normally contain %-codes to interpolate text derived from environment variables.
The %-codes divide the title into pieces, which are spread out to fill the titlebar. This is not done for the icon name, where the pieces are concatenated without spaces between them. Spaces can be inserted in an icon name with %s.
d = shortened directory (from PWD) e = same as d or m (see Choice of d or m) h = hostname (from HOST) i = letter mapping to instance name m = shortened MH folder (from MHPATH) p = printer (from PRINTER) s = space (useful in icons) t = nothing (useful for spreading literal text)
HOME HOST MHPATH PRINTER PWD USER NOSCROLLBAR WIDTH TITLEWIDTH ICONWIDTH
The effect of these is described in the following.
The title is reduced to TITLEWIDTH if that's set, otherwise to WIDTH, otherwise to 80. The intent is that TITLEWIDTH be set for tabbed window managers (Ion), and WIDTH for others (twm etc).
WIDTH should be the terminal width from stty or tput. If zero or empty or undefined then 80 is used. The maximum title width is usually less than WIDTH because the title font is usually larger than the internal font & resizing buttons etc consume space, although a scrollbar adds a bit. If NOSCROLLBAR is not defined then the width of the scrollbar is guessed. The width calculations are rough in that no attempt is made to find out the ratio of the title font and the main font. It is assumed to be 4/3, from the twm & xterm defaults.
ICONWIDTH should be the number of characters that fit in the icon managers or icons. Default is 16. Not adjusted, unlike WIDTH.
A prefix like "/nfs/myhost" is replaced by "myhost:".
A prefix that is the user's home directory is replaced by a tilde.
The "myhost" is omitted if it's the local host.
For icons, the leading component is removed if it's the user's name (USER).
For icons, /tmp/zless.1234/5/ is removed from the start.
Reduced to 3 components.
The code %e gives the same as %d generally, but gives the same as %m prefixed by '=' if the directory would be shortened to a tilde & the MH folder doesn't end in /inbox.
Replaced by "!".
If the title doesn't fit, then the directory name (%d) is shortened from the left till there are no more slashes.
If still too long, the longest of the %interpolations is replaced by a "!", & so on.
If still too long, the last word of the longest piece of literal text is removed, & so on. Shortened pieces have " ..." appended. Can still fail to fit into title bar if there are too many literal pieces.
Same applies to the icon name.
There is no need for the environment variables to be "correct", because xdeco's only interaction with the outside world is via stdout. So if for example you want the title to show the name of a file & shorten it as for directories, you can say (Bourne shell & bash)
PWD=$filename xdeco -t %d -i %d
If the title is 512 characters or more then xterm ignores the control sequence. This is unlikely to happen.
Some xdeco applications can be done more simply with bash's PROMPT_COMMAND. It may be necessary to unset PROMPT_COMMAND for xdeco to work.
Debian has a package called xtermcontrol.
See also xdh -help.
Brian Keck <firstname.lastname@example.org>
$Source: /home/keck/gen/RCS/xdeco,v $ $Revision: 1.77 $ $Date: 2007/07/05 17:00:28 $ xchar 0.2