By wisecracker
It is a DEMO at a glance digital readout using the “date” command to make it useful…
Enjoy…
#!/bin/bash
#
# Clock.sh
# A bash DEMO to create a 6 x 7 character set using the whitespace character.
# It is a functional digital clock but this is not important as I want this
# method for an _at_a_glance_ digital display for a kids level shell digital
# voltmeter I am in the process of doing.
#
# The clock in normal size is white on black near the top. The extra large clock
# is green on black and in the centre of the terminal..
#
# $VER: Clock.sh_Version_1.00.00_(C)2013_B.Walker_G0LCU.
# Issued under GPL2.
#
# Written so the anyone can understand how it works.
# Set the window to white foreground on black background.
printf "x1B[0;37;40m"
clear
# Remove the cursor.
tput civis
# Set up all _variables_ as is required.
TIME=`date "+%H:%M"`
char="0"
# The plot _variable_ "p".
p="(C)2013, B.Walker, G0LCU."
# The background colours.
bg="x1B[0;37;40m"
# The foreground colours.
fg="x1B[0;37;42m"
# The initial character plotting points.
horiz=10
vert=9
# This function reads the time and stores it in "TIME".
clock()
{
TIME=`date "+%H:%M"`
printf "x1B[2;32f$bg The time is $TIME.n"
}
# This function is required to coreectly print out the large characters.
plot()
{
p="x1B["$vert";"$horiz"f"
vert=$[ ( $vert + 1 ) ]
}
# *********************************************************
# The eleven characters required for this DEMO are 0 to 9
# and the : colon character.
zero()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
one()
{
plot
printf "$p$bg $fg $bg "
...read more









