[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A Useful Script




Hi,

I found this while reading through 'Linux Server Hacks'
(Rob Flickenger/O'Reilly) and thought might be useful :

1. Create a script called 'title-top.pl' in ~/bin
    (or some place else in your search path) with the
    following contents


#! /usr/bin/perl -w

# Displays Load Average in the Title Bar of a terminal
# Linux Server Hacks #59, pp.120
# Rob Flickenger; O'Reilly Publications

use strict;
$|++;

my $host=`/bin/hostname`;
chomp $host;

while(1) {
  open(LOAD, "/proc/loadavg") || die "Cannot open /proc/loadavg $!\n";
  my @load=split(/ /,<LOAD>);
  close(LOAD);

  print "\033]0;";
  print "$host: $load[0] $load[1] $load[2] at ", scalar(localtime);
  print "\007";

  sleep 2;
}


2. As usual, change the permission to 755

3. Open a terminal and type, 'title-top.pl &'

4. You should see the load-avg being displayed in the
    title bar of the terminal. When you change directories,
    the CWD (or the dynamically set title) is flashed
    momentarily.

5. Have this line added to ~/.bash_logout

    killall title-top.pl > /dev/null 2>&1


Cheers,
Gowtham

--
S Gowtham
Grad Student
Dept of Physics
Michigan Tech Univ
Houghton MI 49931 USA
http://phy.mtu.edu/~sgowtham