CLI Magic: Three clocks

851

Author: Joe Barr

If you’re like me, you sometimes get so absorbed in work or play that you forget what time it is. The Linux CLI has all sorts of friendly reminders that you can use to keep you from running late for that next important meeting. Come on, lazybones, jump down out of your GUI-hammock, and let’s take a look at three of them.There are two kinds of clocks in the world. The one with hands is an analog clock. Our first CLI timepiece is the other kind — a binary clock. In fact it’s even called binary-clock. It’s really only suited for day-to-day use for geeks or wannabes, but I thought it interesting enough to include in our sampling. Download the tarball, decompress it, and enter the binary-clock subdirectory created by tar. Run make and then — as root — make install
.

On command, binary-clock will print the current time in binary format. Here, for example, is the output from binary-clock at 9:57 AM:

-O----
--OOO-
---O-O
-OOOO-

Here is how to read it. The topmost line (the one that looks like this: -O----) represents a value of 8. The line below it of 4, then 2, then 1. An “O” on a line in the output indicates that the value associated with that line should be included when summing the values of each column.

Applying that to the output above, we can see that the first column is zero, the second is 9 (8 on the top line and 1 on the bottom), the next is 5, the next 7, then five again, then two. So it was 09:57:52 when binary-clock ran.

I don’t know about you, but I give binary-clock poor marks for actually telling the time, simply because I have to think too much about it to find out what time it is. On the other hand, it’s great for impressing others with your geekiness. “What, that old thing? It’s a binary clock. Don’t you have one?”

An audible clock

The second kind of clock provides an audible clue instead of a visual.
One example of that type is grandfatherclock. If it’s not included in your distribution, or if you can’t use the RPM or .deb file provided there, you can download the source and compile it yourself.

As you might expect, by default grandfatherclock sounds just like a grandfather clock. As an extra bonus, the project includes alternative sound files to be used: a cuckoo clock sound, a bell tower sound, and a “Close Encounters” sound.

Once installed, you can run grandfatherclock just by entering its name on the command line. But that’s just good for a single sound-off or a single hour. To really make full use of it you would want to use cron and set it up to chime/toll/tone at times appropriate for you throughout the day.

Here are some of the command-line options available for use:


  • -f filename

    points to a configuration file

  • -a devicename

    points to a specific sound device


  • -t HHMM

    tolls the indicated time


  • -p count

    pauses the tolling an extra second every count tolls


  • -x filename

    x is 1 to 4, for quarter of the hour to sound the filename specified

According to the man page, grandfatherclock is normally executed by cron every hour or every 15 minutes. Please note the usage: the first quarter of the hour comes at 15 minutes after and the fourth quarter at the top of the hour.

Clockywock number three

For our final CLI clock, let’s take a look at an analog clock that features a sweeping second hand — just the thing to be able to check the time from across the room by running full screen.

Seriously, the name is Clockywock. The author explains on his Web site that he is a big fan of “A Clockwork Orange” by Anthony Burgess, so perhaps the name is related to the novel.

Download the latest version from the site, decompress it, enter the subdirectory, and run make. There are no installation notes and the Makefile doesn’t do install, so you can move or copy the executable clockywock wherever you like. There is no license that I can find either, just the source code.

Here’s what Clockywock looks like at almost 5 PM:

I browsed through the source code a bit and discovered that Clockywock was creating a file named .clockywock in my home directory that contained certain values, one of them being an alarm hour and another being an alarm minute. Naturally, I had to alter the file to set those values to something near at hand.

Sure enough, at the appointed alarm time, the window began beeping and blinking like crazy. The space bar acts as a snooze button, by the way, and the Enter key kills the alarm.

Obviously, this is a program still in development, with spit and polish and documentation still to come, but even so it’s fun to play with.

Is it really useful? That depends. If you really want to annoy someone nearby, it could be. And if not to annoy, perhaps to impress. The author claims the clock itself “gets looks from slack-jawed yokels all the time.”