[Top][All Lists]

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

Rotating status bar

From: Alan Young
Subject: Rotating status bar
Date: Thu, 22 Dec 2005 11:02:29 -0700

Someone requested that I send them a copy of my rotating status bar
program but I can't find their email.  I hope its all right to send it
to the list:

First, in your .screenrc add the following line:

backtick 1 60 60 /home/harleypig/screen_statusbar_info

The /home/... is the path and name of the script I wrote.

Add %1` (that's percent one backtick) wherever you want this to appear
in  your hardstatus line.  Here's mine:

hardstatus string "%c:%s %D %m-%d-%Y | %l | %1` | %n %t %W"

The concept is really easy.  The script will run every 60 seconds and
the data will be displayed for 60 seconds (could someone elaborate
what the docs mean by the data will be 'considered valid'?--the data
remains on the screen whatever I set the lifespan to) before it is run
again.  You may want to experiment with some different numbers. 
screen will take the last line of output and put it in place of the

Here's my script.  If you have any questions please feel free to ask. 
Also, I'm experimenting with the backtick 1 0 0 /program option (this
will background the program, or else the program will have to
background itself, I'm not sure yet--and take each line as its printed
and display it).

Oh, and the gmail sub doesn't return the number of messages, it seems
to be broked.

#!/usr/bin/perl -w

use strict;

use Cache::FileCache;
use File::CounterFile;

my $cache = new Cache::FileCache;

my @info = (
  undef, # allow for some error checking

sub readproc {
  my $proc = shift;
  my $PROC;
  return ( open $PROC, "</proc/$proc" ) ? <$PROC> : "Unable to open $proc: $!";

# See
sub iostatus {
  sprintf "IO Status: rate: %06u tokens: %06u",
    readproc( 'io_status' ) =~ /rate=(\d+).*?tokens=(\d+)/;

sub loadavg {
  sprintf "Load Average: %02.2f %02.2f %02.2f",
    split /\s+/, readproc( 'loadavg' );

sub gmail {
  local $^W;
  require WWW::GMail;

  my $gmail = WWW::GMail->new(
    username => "yourgmailusername",
    password => "yourgmailpassword",
    cookies => {
      autosave => 1,
      file => "./gmail.cookie",
    #debug => 1,

  my $login = $gmail->login();
                                                            if (
$login <= 0 ) {                                                       
                                                       print $login ==
0 ?
      "GMail: Unable to login - " . $login->{ 'error' } :
      "GMail: Incorrect password";

  my $new_msgs = grep { $_->[1] == 1 } $gmail->get_message_list( 'inbox' );

  sprintf "GMail: Used %s Total %s (%s) %03d New Messages",
    $gmail->{ 'used' }, $gmail->{ 'total' }, $gmail->{ 'percent_used'
}, $new_msgs;

sub yahooquote {
  require Finance::YahooQuote;
  import Finance::YahooQuote;

  my @keys = (
    'Symbol', 'Company Name', 'Last Price', 'Last Trade Date',
    'Last Trade Time', 'Change', 'Percent Change', 'Volume',
    'Average Daily Vol', 'Bid', 'Ask', 'Previous Close',
    'Today\'s Open', 'Day\'s Range', '52-Week Range',
    'Earnings per Share', 'P/E Ratio', 'Dividend Pay Date',
    'Dividend per Share', 'Dividend Yield', 'Market Capitalization',
    'Stock Exchange', 'Short ratio', '1yr Target Price',
    'EPS Est. Current Yr', 'EPS Est. Next Year',
    'EPS Est. Next Quarter', 'Price/EPS Est. Current Yr',
    'Price/EPS Est. Next Yr', 'PEG Ratio', 'Book Value',
    'Price/Book', 'Price/Sales', 'EBITDA', '50-day Moving Avg',
    '200-day Moving Avg', 'Ask (real-time)', 'Bid (real-time)',
    'Change in Percent (real-time)', 'Last trade with time (real-time)',
    'Change (real-time)', 'Day range (real-time)', 'Market-cap (real-time)',

  my %quote; @quote{ @keys } = getonequote( 'UNTD' );

  my $quote = join ' ', @quote{ 'Symbol', 'Last Price', 'Last Trade Date',
                                'Last Trade Time', 'Change', 'Percent Change',

  print $quote;

my $count = File::CounterFile->new( '/home/harleypig/statusbar.counter' );

if ( $count->value > @info || $count->inc == @info ) {
  $count->dec until $count->value == 1;

print &{ $info[ $count->value ] };

reply via email to

[Prev in Thread] Current Thread [Next in Thread]