binclock and a screensaver script

I have two clocks for the console that I really like — tty-clock and clockywock. A third, binclock, is a curiosity and lacks a few of the “features” that the others have, but it’s worth looking into, for fun.

As you can see, it’s a binary clock with color-coded numbers, ticking off one second at a time, helped along by a conventional, human-readable display on the right. binclock loops with the -l flag, has some primitive color customizations in a binclockrc file, and generally doesn’t tax your system any more than it takes to spit out a few colored numbers.

Personally I’d like to see binclock do a few more things, like center its output on the screen, offer a few more color options or character adjustments while it’s running … things that clockywock or tty-clock do already. But that’s for the programmers to solve, and since I can’t fix it myself, I certainly won’t complain.

And that’s where this could end, except I do enjoy jamming things through figlet now and again. :twisted:

binclock has a “traditional” string of output — a series of binary numbers listed in sequence, rather than in a grid. These mesh nicely with figlet, which means this

binclock -t | figlet -f big -t -c

Shows up in nice big fat letters, centered to your terminal screen. binclock’s built-in looping mechanism doesn’t really work with figlet, since it’s waiting for binclock to “end” before converting the results to large-print edition. In that case, this works fine.

while true ; do clear ; binclock -t | figlet -f big -t -c  ; sleep 1 ; done

Clear the screen, show the time, sleep a second and then go back and do it again, until a real person tells you otherwise. That’s nice too, although there’s no human-readable display, which makes it rather cumbersome as an actual clock.

I’m going to “solve” this the same way I “solved” part of the display for the mocp status screensaver script. This is date, the omnipresent tool for telling time, and sed, which can center things for us.

while true ; do 
	binclock -t | figlet -f big -t -c 
	date +"%T %P" > $HOME/.scripts/header.txt 
	sed  -e :a -e 's/^.\{1,133\}$/ &/;ta' -e 's/\( *\)\1/\1/' $HOME/.scripts/header.txt 
	sleep 10

It’s a little fatter now, but will sit neatly in a script file, waiting to be cued by something like screen’s blanker option.

I notice on my Pentium that there’s a slight lag while sed calculates the line length and pads the time before printing it; for that reason and because I don’t have a need for an every-second update, I changed the sleep length to 10 seconds. Do as you will though. It’s all about freedom. ;)

About these ads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Visit the Wiki!

Some recent desktops

May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF

May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games

Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers


This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,960,707 hits



Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: