#!/bin/sh # I'm forgetful of these things today=$(date '+%m/%d') run_date=$(date '+%Y-%m-%d') #F_BDAY_RECORDS="bdays.txt" F_BDAY_RECORDS=~/.local/share/bdays.txt BDAY_IMG=~/Digital/Pictures/Backgrounds/birthday.png last_run=$( grep '^# last run:' "$F_BDAY_RECORDS" 2>/dev/null \ | tail -n1 \ | awk '{ print $4 }' ) [ "$last_run" = "$run_date" ] && exit 0 BDAY_LIST=$(awk -v td="$today" ' $0 ~ /^[[:space:]]*#/ { next } # skip comments NF < 3 { next } # skip malformed $1 == td { printf("%s %d\n", $3, $2 + 1) } ' "$F_BDAY_RECORDS") [ -z "$BDAY_LIST" ] && exit 0 magick -size 800x600 canvas:black \ -gravity north -font 'Adwaita-Sans-Bold' -pointsize 72 -fill white \ -annotate +0+50 'Birthdays Today' \ -gravity center -font 'Adwaita-Sans' -pointsize 36 \ -annotate +0+100 "$BDAY_LIST" \ ~/Digital/Pictures/Backgrounds/birthday.png awk -v td="$today" ' /^# last run:/ { next } # drop old last-run $0 ~ /^[[:space:]]*#/ { print; next } # preserve other comments NF < 3 { print; next } # preserve blanks/malformed $1 == td { $2 = $2 + 1 } # bump age { print $1, $2, $3 } # print all records ' "$F_BDAY_RECORDS" > bdays.tmp echo "# last run: $run_date" >> bdays.tmp mv bdays.tmp "$F_BDAY_RECORDS" xwallpaper --output HDMI-A-0 --center "$BDAY_IMG"