Simple Binary Bash Clock  
Saturday, October 1, 2011, 12:01
Posted by Administrator
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.
add comment ( 8633 views )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 5238 )

<<First <Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Next> Last>>