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.😈

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.😉

4 thoughts on “binclock and a screensaver script

  1. ing

    You can pipe the output of date directly into sed and thereby get rid of that temporary file.

  2. Pingback: vtclock: One more console clock can’t hurt « Motho ke motho ka botho

  3. Pingback: Some Crux ports for console clocks « Motho ke motho ka botho

  4. Pingback: One tool, one game, one clock « Motho ke motho ka botho

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