« Blue Dot brings new experiences to our everyday life | Main | Add variable support to CSS with Emacs and Perl/Template::Toolkit »

How to make GNU screen indicate the count of unread entries on livedoor Reader

lurker-san posted an entry describes how we can make GNU screen indicate the count of unread entries on livedoor Reader on its hardstatus line. It's interesting.

Well, I think lurker-san's approach might provoke too much frequent access to LDR's API.

screen.info says:

Command: backtick ID LIFESPAN AUTOREFRESH COMMAND [ARGS]

(snip)

The specified LIFESPAN is the number of seconds the output is considered valid. After this time, the command is run again if a corresponding string escape is encountered.

How about the problem? I'm not sure that I've understood what the document describes...

So then, I'll show you another solution. typester told me it. See for the Bloglines version: .

Meanwhile, screen.info says:

If both the LIFESPAN and the AUTOREFRESH parameters are zero, the backtick program is expected to stay in the background and generate output once in a while.  In this case, the command is executed right away and screen stores the last line of output. If a new line gets printed screen will automatically refresh the hardstatus or the captions.

I'll apply this feature to this one.

First, after setting your user name on livedoor Reader as "USERNAME", save the code below as a file named "ldrcheckunread", and locate it on the path your system can find it.

#!/bin/sh

USERNAME='user name'
INTERVAL=600

while true;
  do
  echo "updating..."

  STATUS=''
  RESPONSE=`curl -s http://rpc.reader.livedoor.com/notify?user=$USERNAME | tr -d '|'`

  expr "$RESPONSE" + 1 > /dev/null 2>&1
  if [ $? -lt 2 ]; then
    STATUS=$RESPONSE
  else
    STATUS='Error!'
  fi

  echo "LDR($STATUS)"
  sleep $INTERVAL
done

Second, add a snippet like below to your .screenrc file. What kind of the settings suits for your system depends on your like, so edit it as you like.

backtick 0 0 0 ldr_check_unread
hardstatus alwayslastline "%H[%02c]: %` %-w%{=b bw}%n %t%{-}%+w"

Finally, you'll see the thing like below on your terminal.

screen's hardstatus

Let's enjoy the comfortable life with GNU screen and livedoor Reader!

TrackBack

Listed below are links to weblogs that reference How to make GNU screen indicate the count of unread entries on livedoor Reader:

» [etc]LivedoorReader未読数表示の件 from 技術メモ帳
ma.la さん / antipop さん 申し訳ありませんでした。 元記事を修正しておきました。 3 - 600(10分) [Read More]

About

This page contains a single entry from the blog posted on July 22, 2006 12:51 AM.

The previous post in this blog was Blue Dot brings new experiences to our everyday life.

The next post in this blog is Add variable support to CSS with Emacs and Perl/Template::Toolkit.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34