A wrapper for osd_cat

Posted on Mon 22 June 2009 in Technology • 2 min read

Few months ago, we discussed about a mail notification method for fetchmail/procmail and mutt combo. As you can see in that post, the script we wrote to handle notification was dependent on ratpoison. Well it makes life bit tough for my non-ratpoison X sessions. I thought it would be a good idea to make the script window manager independent. Enter osd.sh

The script uses osd_cat. It comes in the XOSD package for most of the unices. It is similar to the cat command for the console. It can read a file, string or the stdin and output the text onto X display. It has a bunch of config options which let you choose font, location etc. for the text. I’d recommend a RTM (man osd_cat).

Here is the code:

#!/bin/bash

# Displays a string on the screen

# Last Modified: Mon 22 Jun 2009 02:59:55 AM IST

# let osd know, we have a X running. there will be problems if this script is

# called from different user. disable acl in X in that case(use xhost +).

export DISPLAY=”:0.0”

color=”red”

font=”-*-dina-medium-r-normal-*-16-*-*-*-*-*-*-*”

age=”6”

align=”center”

delay=”4”

indent=”0”

lines=”5”

offset=”0”

shadow=”1”

pos=”middle”

# read from stdin if no args are present

if [ \$# -ne 1 ]

then

text=\$(line)

else

text=\$1

fi

echo \$text | osd_cat —color=\$color —delay=\$delay —age=\$age —font=\$font —offset=\$offset —shadow=\

\$shadow —lines=\$lines —align=\$align —pos=\$pos

This script can be used for any notification purpose. For using this with procmail, replace use the following construct in procmailrc:

:0 h

| grep “From:” | /home/arun/bin/osd.sh

This will display alerts as “From: Foo Bar ” when a new mail is received.

Enjoy!