User-LED clock script

My user-LED clock, to see the time when I need it (there’s no hardware clock in my room). Just wait until the clock starts and count the hours/quarters. To be called every minute using cron :slight_smile:

#!/bin/bash

rainbow usr1 enable
rainbow usr2 enable
sleep 2
rainbow usr1 disable
rainbow usr2 disable
sleep 1

function show_hours {
	HOUR=`date +%I`
	for i in `seq 1 $HOUR`
	do
		rainbow usr1 enable
		sleep .3
		rainbow usr1 disable
		sleep .3
	done
}

function show_minutes {
	QUARTER=$((`date +%M`/15))
	for i in `seq 1 $QUARTER`
	do
		rainbow usr2 enable
		sleep .3
		rainbow usr2 disable
		sleep .3
	done
}

show_hours & show_minutes
wait
1 Like