31 lines
1 KiB
Bash
31 lines
1 KiB
Bash
read -rd "" cal_events <<'EOF'
|
|
3,17,Saint Patrick's day,Happy,🍀
|
|
10,31,Halloween,Have a spooky,🎃
|
|
12,25,Christmas,Merry,🌲
|
|
*,Friday,Friday,Happy,🚀
|
|
EOF
|
|
|
|
if [[ -f ${XDG_CONFIG-"$HOME"/.config}/events.csv ]]; then
|
|
cal_events=$(< "${XDG_CONFIG-"$HOME"/.config}"/events.csv)
|
|
fi
|
|
|
|
read -r cur_{month,day} dow < <(date "+%m %d %A")
|
|
|
|
while IFS=, read -r ev{_{month,day},} celebrate sym; do
|
|
if [[ $ev_month = '*' ]] || (( 10#$cur_month == 10#$ev_month )); then
|
|
if [[ $ev_day = '*' || ${ev_day,,} = ${dow,,} ]]; then
|
|
printf -v ev_banner '%s %s!\n' "$celebrate" "${ev^}"
|
|
elif [[ $ev_day =~ ^[0-9]+$ ]] && (( 10#$cur_day == 10#$ev_day )); then
|
|
printf -v ev_banner '%s %s!\n' "$celebrate" "${ev^}"
|
|
elif [[ $ev_day =~ ^[0-9]+$ ]] && (( 10#$cur_day < 10#$ev_day )); then
|
|
printf -v ev_banner 'Only %d days until %s!\n' "$(( 10#$ev_day - 10#$cur_day ))" "${ev^}"
|
|
fi
|
|
|
|
if [[ -v ev_banner ]]; then
|
|
printf %s "$ev_banner"
|
|
prompt_symbol=$sym
|
|
fi
|
|
|
|
break
|
|
fi
|
|
done <<< "$cal_events"
|