diff --git a/bin/holiday b/bin/holiday new file mode 100755 index 0000000..4c20f1b --- /dev/null +++ b/bin/holiday @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +HOLIDAY=~/.local/holiday.csv +JQ_CSV_FMT='.holiday[] | "\(.date),\(.holiday),\(.name)"' + +# update holiday database +update_holiday() { + curl http://timor.tech/api/holiday/year/$(date +%Y) | jq "$JQ_CSV_FMT" -r > $HOLIDAY + if [ $(date +%m) -eq 12 ]; then + curl http://timor.tech/api/holiday/year/$(date -d '+1 year' ) >> $HOLIDAY + fi +} + +format_date() { + date -d "$1" +%Y-%m-%d +} + +is_holiday() { + DATE=$(format_date $1) + IS_HOLIDAY=$(awk -F, '$1=="'$DATE'" { print $2 }' $HOLIDAY) + if [ -n "$IS_HOLIDAY" ]; then + [ "$IS_HOLIDAY" = "true" ] + else + WEEKDAY=$(date -d "$1" +%w) + [ "$WEEKDAY" -eq 6 ] || [ "$WEEKDAY" -eq 0 ] + fi +} + +# automatically update if file didn't exist +[ ! -f "$HOLIDAY" ] && update_holiday + +case "$1" in + update) + update_holiday + ;; + *) + is_holiday "$@" + ;; +esac diff --git a/gui/dwm/autostart b/gui/dwm/autostart index e9f3ad4..7bd0248 100755 --- a/gui/dwm/autostart +++ b/gui/dwm/autostart @@ -24,4 +24,10 @@ launchapp flameshot launchapp ibus-daemon -drx launchapp nextcloud --background +if ! holiday today; then + launchapp thunderbird + launchapp chromium + launchapp st -c class workterm +fi + nitrogen --restore