diff options
Diffstat (limited to 'bin/clock.sh')
-rw-r--r-- | bin/clock.sh | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/bin/clock.sh b/bin/clock.sh index 5b54a6a..0a36087 100644 --- a/bin/clock.sh +++ b/bin/clock.sh @@ -9,16 +9,48 @@ do if [ $TODAY -ne $OLD_TODAY ] then - MONTH=`date +'%m' | sed "s/^0//"` - YEAR=`date +'%Y'` + MONTH=$(date +'%_m') + YEAR=$(date +'%Y') [ $MONTH -eq 12 ] && YEAR=$(($YEAR + 1)) OLD_TODAY=$TODAY echo "^cs()" - echo - cal -m | 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/" + 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; \ + + # 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; \ + + # 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 |