 
 sysline  -- statusline display utility for Linux
 
 INTRO
 
 Well, I saw the sysline utility mentioned in the O'Reilly book on BSD and
 found no such thing for Linux, so took a stab at porting it myself.  The
 result is before you.  The original sources are included here in ./BSD.
 
 I'm no C expert nor a Unix expert, so if this port aggravates you, feel
 free to improve on it; I guess that was partly my intention. Flames, praise
 comments, changes and additions are all welcome.
 
 I have not been able to test it under emacs yet, perhaps one of these days. 
 Incidentally, I believe emacs has a built-in utility that sort of does what
 sysline does.  The rwho stuff I tested against some dummy whod files - I
 think it works, but check it out.
 
 The reporting of login/logout of users may be a bit flaky if you're not
 using getty_ps v2.0.7d or later (which differ in utmp logging from v2.0.7c)
 or if you're using a mix of getty's. I got the impression everyone has his
 own way of logging things to utmp.

 INSTALL
 
 Read the file CHANGES for a quick overview of possible changes in the
 termcap/terminfo capability strings.
 
 The program assumes presence of the /proc filesystem (which prob. everybody
 has nowadays).  If you don't have it, you've got three choices at this
 time: don't use sysline, recompile the kernel to include /proc, or send me
 diffs to get process info from /dev/kmem.  I might do the latter myself,
 but don't hold your breath.
 
 Compile with TERMINFO in the Makefile defined to use terminfo, comment it
 out to use termcap.  If you compile for terminfo, you need to have the
 ncurses package installed (Zeyd M. Ben-Halim's ncurses-1.85 for instance). 
 If you compile for termcap, you can now choose between plain curses
 or ncurses. For details, see the Makefile.

 The file config.h has some other compiling options you can to change to
 your liking.  Running `make' will compile sysline, `make install' will
 install sysline and sysline.1 in the paths as per the Makefile.  If you're
 using the rhwo feature, note that the files are read for info are called
 /var/spool/rwhod/whod.<remotehost>, as defined in pathnames.h.  Again, I
 tested this rwho stuff with some dummy whod files and I believe it works.

 Your /etc/termcap or /usr/lib/terminfo/<your_terminfo_file> -whichever
 you're using- might be lacking some capabilities that sysline
 needs/appreciates.  They are for /etc/termcap:

	:hs:\					has status line
	:es:\					esc in status line ok
	:ws#80:\				width of status line
	:i2=\E[1;24r\E[H\E[J:\			initialization string
	:ts=\E7\E[m\E[%i25;%dH\E[1K:\		move to status line
	:fs=\E[0K\E8:\				move from status line
	:ds=\E7\E[25;1H\E[2K\E8:\		disable status line
	:cs=\E[%i%d;%dr:\			change scroll region
	:so=\E[7m:\				begin standout mode
	:se=\E[m:\				exit standout mode
	:ce=\E[K:\				clear to end of line
	:bl=^G:\				audible signal (bell)

 and their /usr/lib/terminfo/<your_terminfo_file> equivalents:
 
	hs,					has status line
	eslok,					esc in status line ok
	wsl#80,					width of status line
	is2=\E[1;24r\E[H\E[J,			initialization string
	tsl=\E7\Em\E[%i25;%p1%dH\E[1K,		move to status line
	fsl=\E[0K\E8,				move from status line
	dsl=\E7\E[25;1H\E[2K\E8,		disable status line
	csr=\E[%i%p1%d;%p2%dr,			change scroll region
	smso=\E[7m,				begin standout mode
	rmso=\E[m,				exit standout mode
	el=\E[K,				clear to end of line
	bel=^G,					audible signal (bell)	
 
 You may wish to change the 80 in ws/wsl, 24 in i2/is2 an 25 in ts/tsl
 according to your particular setup.  You should NOT have a ws/wsl string in
 the xterm termcap/terminfo entry, so that instead sysline can figure it out
 itself at startup, and change it correctly each time the window's size
 changes.  You might as well leave it out from your regular termcap/terminfo
 entry too.
 
 (Note: the bl/bel, is/is2 and ce/el strings are additions and the ts/tsl
 strings have changed from the first release of sysline; you may want to
 add/change them).
 
 There is an addition to the ts/tsl strings.  Insert \Em _after_ the \E7;
 this will reset the cursor attributes to their defaults (\E7 saves the
 cursor state first) before displaying the status line.  This should avoid
 problems with a messy statusline when you're working for instance with an
 editor.

 HINTS
 
 In order to create a status line area that won't be interfered with and
 won't be messed up by editors and the like, you need to do something like
 `stty rows 24' (when your terminal has 25 rows).  This should be sufficient
 _if_ you have the appropriate i2/is2 strings in your termcap/terminfo file
 (see example above), since these i2/is2 capabilities will be issued by
 sysline when it starts.  What this does is set the scroll region for the
 terminal to the area specified in these strings - the stty call should
 correspond with the numbers in these strings, by the way.
 If you don't have the i2/is2 strings in your termcap/terminfo file, you can
 instead use the cs shell-script. It will issue the stty call, and set the
 scroll region. Call it with the number of lines in the scroll region as an
 argument, e.g. `cs 24'.  I'm calling it cs by the way because that's the
 name of the termcap capability to set the scroll region.
  
 Use the -w flag for instance when running sysline in a 1-line xterm.
 
 To force an update of the statusline, do `kill -SIGALRM sysline'.
 
 Since I hate it when doing a `cls' or `clear' erases my statusline, I've
 added a (generally useful) cls utility that clears the screen but leaves
 the statusline alone. It gets the screen size from stty and can be used on
 screens without a statusline as well.  I also use it in my reset shell
 script.  
 Also, when I start up an editor like joe, it normally clears the entire
 screen, including the statusline.  I changed the cl capability under the
 `ansi' entry in my termcap file (the "clear" string in the terminfo file if
 you've got joe using you terminfo file) to cl=\E[24;80H\E[1J\E[H.  This
 does something similar like cls does, and it happens to work on a normal
 25-line screen as well.  What's more, now `tput clear' also leaves the
 statusline alone, obviating the need for the cls utility - we've come full
 circle; cls is more flexible though.

 If you run sysline as root (not as another user), it keeps running after
 you log out (without it actually updating the statusline anymore, since any
 attempt to write to stdout without a controlling terminal will result in an
 I/O error).  This happens with getty_ps at least (2.0.7c and later), not
 with getty4.20 by Fred van Kempen, I don't know about other getty's, nor
 why they behave so differently and what sort of behaviour would be the
 correct one. Can any UNIX guru tell me what's going on here?  Anyway, to
 avoid this, you could start it like:
 
        	sysline -i >~/sysline.pid
 	       
 and then have:
 
		kill -HUP `cat ~/sysline.pid`
		rm -f ~/sysline.pid
	
 in your ~/bash_logout, or something more elaborate.
 

 Enjoy.
 
				- Bauke Jan Douma
				``in the software business since tuesday''
				bjdouma@xs4all.nl
