#!/bin/sh

daily () {
	# ihostart and bandwagonhost announcements rss/atom feed are not working,
	# so I put them here instead.
	o "$BROWSER" \
		https://github.com/notifications \
		'https://mail.google.com/mail/u/0/#inbox' \
		'https://mail.google.com/mail/u/0/#spam' \
		https://discord.com/channels/@me \
		https://en.wikipedia.org/wiki/Portal:Current_events \
		'https://panel.ihostart.com/index.php?rp=/announcements' \
		https://bwhstatus.com/ \
		https://app.element.io/#/room/#archlinux-pinephone:kde.org \
		https://www.hoyolab.com/circles/6/39/official \
		'https://lzhr.luxsan-ict.com:8443/lz_mobile/#/checkingIn'
	# alacritty --hold must be before -e
	# full window: -w156, am and pm in one line: -w114
	o alacritty --hold -e rem -cu+2 -@ -w114
	o alacritty --hold -e wtr
	o alacritty -e newsboat
	o alacritty --hold -e rate
	o alacritty -e neomutt
	o alacritty -e prp
	o alacritty -e prp master2
	o alacritty -e prp master3
	o alacritty -e prp practice_password4
	o alacritty -e prp practice_password5
}

monthly () {
	o "$BROWSER" http://download.huzheng.org
	# Show 3 months' remind. Old reason for 3 months is not valid any more, but I like this period and my calculation so I decided to keep it.
	# (2*31+30+6)/7=14. Consider month 1 day 1 is on Sunday and make sure month 3 day 31 is shown. Tested with `rem -cu+14 -@ -w114 2025-03-01`
	o alacritty --hold -e sh -c 'rem -cu+14 -@ -w114 | "$PAGER"'
}

if [ $# -eq 0 ]; then
	daily
else
	while getopts m opt; do
		case $opt in
			m) monthly;;
			\?) exit 1;;
		esac
	done
fi
