Simple Binary Bash Clock  
Saturday, October 1, 2011, 15:01
I've been meaning to post this for a while, but recently I made a small binary clock in bash in order to add it to my conky configuration.

The script that follows below basically all it does is get the current hour minute and second fields and then convert it to display in binary.
It then clears the screen and updates once a second to look exactly like I want it to.


#!/bin/bash
while true;
do
clear
hour=$(date +%H)
minute=$(date +%M)
second=$(date +%S)
hour_binary=$(echo "ibase=10;obase=2;$hour" | bc)
minute_binary=$(echo "ibase=10;obase=2;$minute" | bc)
second_binary=$(echo "ibase=10;obase=2;$second" | bc)
printf "%06d\n" "$hour_binary"
printf "%06d\n" "$minute_binary"
printf "%06d" "$second_binary"
sleep 1
done


Here is an example of the clock in action with the font blown way up:



The more I work with scripting things the more ways I can think of to apply scripts.

Its an ongoing cycle.

Comments

Add Comment
Fill out the form below to add your own comments.









Insert Special:






Moderation is turned on for this blog. Your comment will require the administrators approval before it will be visible.