unixb4coffee profile image

Linux for Users: Animation with X Window System Icons

Animated iclock and ibanner icons on a Linux Motif desktop.
Animated iclock and ibanner icons on a Linux Motif desktop.

The two programs here, "iclock," and, "ibanner," are simple, and, hopefully, useful programs that demonstrate how displaying animation on Linux desktops is as easy as accomplishing the same tasks on Windows or Macintosh displays.

Linux desktops are actually capable of displaying fantastic, animated graphics. The main difficulty, as usual, is that Linux and the the X Window System provide so many options that it's difficult for beginners to navigage through all of the programs and libraries needed to accomplish any task.

Displaying anything using Linux is often complicated by the fact that a machine can use any of several different desktops. The programs here, which you can download from the links below, can work with desktops that use pixmaps for icons, like Motif's, "mwm," as well as desktops with task bars that use mini-icons, like, "nautilus," and, "xfce," and desktops that don't use graphical icons on their taskbars, like, "fvwm."

However, the basic technique is the same: the programs continuously update the icon's graphics, and notify the desktop program of the change. Because many window managers display the window's title as the icon title, the program updates the window's title also. However, because these programs display only icons, the actual windows do not need to be made visible, and the programs tell the desktop software to display only the title and the icon image on the screen.

As usual, "iclock," and, "ibanner," are self contained. They require only the basic Xlib libraries and headers. After downloading and unzipping the files from the source code below, you can build and install them with a few commands.

$ make
$ su      # Enter the superuser password.
# make install

After that, you can display each program's options by typing, "iclock -h," or, "ibanner -h," at the shell prompt.

The, "iclock," options are relatively simple. On a desktop that uses graphical icons, the options allow you to display either a digital or analog clock. The program also updates the icon label with the date and time, and so it provides continuous updates on systems that use text in the task bar.

The options for, "ibanner," are a little more complicated, because, "ibanner," allows you to update the text in an icon that is already on the screen. Here are a few examples.

# To start displaying a banner icon.
$ ibanner -t "This is the icon's title." -e "This is the text."

# To display a banner icon that you want to update, use the
# -v option.  Ibanner prints its process id, which you can use
# to update the text later.  You can also find the process id
# using, "ps."
$ ibanner -v -t "Title" -e "Text in the icon."
3485     
...
# Then, to update the banner text, give the process id of the
# banner as an argument with, "-c."
$ ibanner -c 3485 -e "New text that you want to display."

That makes, "ibanner," useful for all sorts of system monitoring tasks. One of the oldest is monitoring your system's mail directory for new mail. These programs are commonly known as, "biffs," probably after someone's name in the early days of UNIX networking when people began sending e-mail messages to each other. So here's a shell script that uses, "ibanner," as a biff. You can call the script, "ibiff," or something similar, and keep it in a convenient place. (Note that the local mail directory does not include any messages you send and receive using a Web browser.)

#!/bin/bash

# Change if the mail spool directory on your
# machine is different.
MAILDIR=/var/spool/mail
MAILSIZE_INIT=`ls -l $MAILDIR/$LOGNAME | awk '{print $5; }'`

if [ $MAILSIZE_INIT -gt "0" ] ; then 
    ibanner -v -t Mail -e "You have mail." > /tmp/ibiff.pid &
else
    ibanner -v -t Mail -e "No mail." > /tmp/ibiff.pid &
fi

PID=`cat /tmp/ibiff.pid`
rm -f /tmp/ibiff.pid

while [ true ]; do
    MAILSIZE_NEW=`ls -l $MAILDIR/$LOGNAME | awk '{print $5; }'`
    if [ $MAILSIZE_NEW -gt $MAILSIZE_INIT ]; then
	ibanner -c $PID -e "You have new mail."
        MAILSIZE_INIT=$MAILSIZE_NEW
    elif [ $MAILSIZE_NEW -eq "0" ]; then
	ibanner -c $PID -e "No mail."
        MAILSIZE_INIT=$MAILSIZE_NEW
    fi
    sleep 3
done

 Last updated on January 12, 2012

Useful Funny Awesome Beautiful Interesting 

Comments 3 comments

blag 2 years ago

I've always thought that X should have tons of really small snippets of code or tiny static libraries that let you set these things up on your own to minimize the duplication of coding simple things with X.

Also, do you think you could get a more up-to-date screenshot using a Qt or GTK+ application? It's kind of ironic to be extolling the usefulness of X when your screenshot is of the Motif toolkit and Emacs. I suppose you'd need more than the standard X libraries then.

Roland 2 years ago

The original biff program was named after the programmer's dog, because it would always bark when the mailman showed up. This fact brought to you by the 1980's.

unixb4coffee profile image

unixb4coffee 2 years ago Hub Author

There's no short answer for me to favor a particular toolkit over another. Xlib is sort of a, "lowest common denominator," library, and all systems already have it, so non-programmers need to install only a minimum of extra packages to install and use the programs here.

I agree that there could be more modularization of GUI utilities, and these programs are designed to be self contained. Installing a widget toolkit from scratch, if the Linux distro doesn't have the correct packages or widget versions, can be a serious chore. Widget toolkits aren't very self contained. Besides, I don't have the time to try all of them, and I don't publish anything here that I don't try myself.

I know that Motif is going to become older that retro, but I still prefer it for my own use because it's mature, rock-steady in its interaction with window events and memory, and mwm still presents the sharpest 3-d appearance of any window manager (in my own opinion).

The programs here also work at least predictably with desktop programs like Nautilus, fvwm, xfce, and I'm working on adding Metacity and Enlightenment here. The protocol for desktop programs is getting upgraded. These programs use Xlib's window manager hints, and they also work consistently with the programs I just mentioned, which use the newer Extended Window Manager Hints standard. Linux of all operating systems is the only one that doesn't have a standard desktop (doesn't need one, either), but graphics programs need to cope with all of these protocols.

As for the name, "biff," I knew the program had to be named after something. Some people think that dogs are also people. Thanks for the information.

    Sign in or sign up and post using a HubPages account.

    8192 characters left.
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your Hubs or other sites.


    Like This Hub?
    Click to Rate This Article
    Please wait working