Published: 9. 1. 2012   Category: GNU/Linux

Big clock

This is another bash play to demonstrate ability of the command line interface. Try to use your terminal as huge digital clocks:

    
    ▀▀▀▀    ▀▀▀▀            ▀▀▀▀▀    ▀▀            ▀▀▀▀▀▀   ▀▀▀▀ 
   ▀▀  ▀▀  ▀▀  ▀▀          ▀▀   ▀▀  ▀▀▀            ▀▀      ▀▀  ▀▀
       ▀▀      ▀▀    ▀▀    ▀▀  ▀▀▀   ▀▀      ▀▀    ▀▀▀▀▀       ▀▀
     ▀▀▀     ▀▀▀     ▀▀    ▀▀ ▀ ▀▀   ▀▀      ▀▀        ▀▀    ▀▀▀ 
    ▀▀      ▀▀             ▀▀▀  ▀▀   ▀▀                ▀▀   ▀▀   
   ▀▀      ▀▀        ▀▀    ▀▀   ▀▀   ▀▀      ▀▀    ▀▀  ▀▀  ▀▀    
   ▀▀▀▀▀▀  ▀▀▀▀▀▀    ▀▀     ▀▀▀▀▀  ▀▀▀▀▀▀    ▀▀     ▀▀▀▀   ▀▀▀▀▀▀

The following code use a console font stored in PSF format, the size of char is 8x8. The format is quite simple, the hexadecimal numbers on specific positions correspond to microlines of bitmap char. So, I convert them to the binary representation, and ones are displayed as „▀“ character, zeros as spaces.

#!/bin/bash
F=(`zcat /lib/kbd/consolefonts/drdos8x8.psfu.gz| hexdump -v -e'1/1 "%x\n"'`)
e=echo\ -e;$e "\033[2J\033[?25l"while true; do A=''  T=`date +" "%H:%M:%S`
$e "\033[0;0H" ; for in `eval $e {0..$[${#T}-1]}`; do a=`$e -n ${T:$c:1}|\
hexdump -v -e'1/1 "%u\n"' `; A=$A" "$[32+8*a]; done;for in {0..7};do for \
in $A; do d=0x${F[$[i+j]]} m=$((0x80)); while [ $m -gt 0 ] ; do bit=$[d&m]
$e -n $[bit/m]|sed -e 'y/01/ ▀/';: $[m>>=1];done;done;echo;done;done # BruXy