summaryrefslogblamecommitdiffstats
path: root/bin/clock.sh
blob: 8b26f9f468bcdefff93d2a496d024d34c356fde7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                       

                                    



                                                        

                                              









                                                                                       
                                      



                                                
                                









                                                                                                             
                                      


                                                





                                                                                                                                                                



               
#!/bin/sh
OLD_TODAY=0

while /bin/true
do
	echo "^tw() ^fg(#ff0000)`date`"

	TODAY=$(expr `date +'%d'` + 0)
	
	if [ $TODAY -ne $OLD_TODAY ]
	then
		MONTH=$(date +'%_m')
		YEAR=$(date +'%Y')
		[ $MONTH -eq 12 ] && YEAR=$(($YEAR + 1))
		OLD_TODAY=$TODAY

		echo "^cs()"
		if hash gcal 2>/dev/null; then
			echo
			gcal --cc-holidays=DE_BE --starting-day=Mon "${MONTH}" | sed "\
			    # highlight current day
			    s/<\(\( \|[0-9]\)[0-9]\)>/ ^fg(#ff0000)\1^fg() /; \

			    # hightlight holiday
			    s/:\(\( \|[0-9]\)[0-9]\):/ ^fg(#ffff00)\1^fg():/g; \
			    s/:\(\( \|[0-9]\)[0-9]\):/ ^fg(#ffff00)\1^fg():/g; \

			    # remove leftover holiday marker
			    s/:\(\( \|[0-9]\)[0-9]\)/ \1/g; \
			    s/:$//g; \

			    # remove empty lines
			    /^[ \t]*$/d"

			echo " "
			gcal --cc-holidays=DE_BE --starting-day=Mon "$((($MONTH % 12) +1))" "$YEAR" | sed  "\
			    # highlight current day
			    s/<\(\( \|[0-9]\)[0-9]\)>/ ^fg(#ff0000)\1^fg() /; \

			    # hightlight holiday
			    s/:\(\( \|[0-9]\)[0-9]\):/ ^fg(#ffff00)\1^fg():/g; \
			    s/:\(\( \|[0-9]\)[0-9]\):/ ^fg(#ffff00)\1^fg():/g; \

			    # remove leftover holiday marker
			    s/:\(\( \|[0-9]\)[0-9]\)/ \1/g; \
			    s/:$//g; \

			    # remove empty lines
			    /^[ \t]*$/d"
		else
			echo
			cal -m ${MONTH} | sed "s/$/                    /;s/^\(.\{20\}\).*$/\1/" | sed -u -re "s/(^|[ ])($TODAY)($|[ ])/\1^fg(#ff0000)\2^fg()\3/"
			echo " "
			cal -m $((($MONTH % 12) +1)) $YEAR | sed "s/$/                    /;s/^\(.\{20\}\).*$/\1/"
		fi
	fi

	sleep 1
done