#!/bin/csh
#
# Aperture Schedule Viewer: a free and efficient digital schedule utility
# https://www.aperture.akron.oh.us/~schedule/viewer.html
#
# Copyright (C) 2025 Anton McClure <asm@aperture.akron.oh.us>
# All rights reserved.
#
# AkroCal-specific files should be removed.
#
service akrocal stop
rm -rf /usr/local/share/akrocal/
rm /etc/rc.d/rc.akrocal
rm /etc/cron.d/akrocal
rm /etc/X11/xorg.conf.d/10-akrocal.conf
rm /usr/local/bin/akrocal
#
# End
#
rm -rvf /tmp/schedview*
pkg install -y wget xinit xorg xorg-fonts drm-kmod xf86-video-intel xorg-fonts xorg-fonts-100dpi xorg-fonts-75dpi xorg-fonts-cyrillic xorg-fonts-miscbitmaps xorg-fonts-truetype xorg-fonts-type1 xorg-fonts xorg-fonts-100dpi xorg-fonts-75dpi xorg-fonts-cyrillic xorg-fonts-miscbitmaps xorg-fonts-truetype xorg-fonts-type1 xfontsel font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi font-adobe-utopia-75dpi font-adobe-utopia-type1 font-alias font-amsfonts font-arabic-misc font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 font-cronyx-cyrillic font-cursor-misc font-daewoo-misc font-dec-misc font-gost font-ibm-type1 font-isas-misc font-jis-misc font-micro-misc font-misc-cyrillic font-misc-ethiopic font-misc-meltho font-misc-misc font-mutt-misc font-schumacher-misc font-screen-cyrillic font-sony-misc font-sun-misc font-tex-gyre-bonum-math font-tex-gyre-pagella-math font-tex-gyre-schola-math font-tex-gyre-termes-math font-util font-winitzki-cyrillic font-xfree86-type1
mkdir -p /usr/local/share/schedview /usr/local/bin
wget ftp://ftp.aperture.akron.oh.us/coblabs/cal/ico.xpm -O /usr/local/share/schedview/ico.xpm
/usr/local/bin/wget -O- ftp://ftp.aperture.akron.oh.us/schedule/schedview/setup.csh | csh
mkdir /usr/local/etc/schedview/
set hostname = `hostname -s`
echo '/* Aperture Schedule Viewer: a free and efficient digital schedule utility' > /usr/local/etc/schedview/config.ini
echo ' * https://www.aperture.akron.oh.us/~schedule/viewer.html' >> /usr/local/etc/schedview/config.ini
echo ' *' >> /usr/local/etc/schedview/config.ini
echo ' * Copyright (C) 2025 Anton McClure <asm@aperture.akron.oh.us>' >> /usr/local/etc/schedview/config.ini
echo ' * All rights reserved.' >> /usr/local/etc/schedview/config.ini
echo ' */' >> /usr/local/etc/schedview/config.ini
echo '[General]' >> /usr/local/etc/schedview/config.ini
echo 'refresh_int=60' >> /usr/local/etc/schedview/config.ini
echo 'view_days=3' >> /usr/local/etc/schedview/config.ini
echo 'font_m=-*-helvetica-medium-r-normal-*-24-*-*-*-*-*-*-*' >> /usr/local/etc/schedview/config.ini
echo 'font_a=-*-times-bold-r-normal-*-25-*-*-*-*-*-*-*' >> /usr/local/etc/schedview/config.ini
echo 'font_l=-*-new century schoolbook-bold-r-normal-*-34-*-*-*-*-*-*-*' >> /usr/local/etc/schedview/config.ini
echo 'font_d=-*-helvetica-medium-r-normal-*-20-*-*-*-*-*-*-*' >> /usr/local/etc/schedview/config.ini
echo 'font_i=-*-new century schoolbook-bold-r-*-*-17-*-*-*-*-*-*-*' >> /usr/local/etc/schedview/config.ini
echo 'regex=^([^[:space:]]+[[:space:]][^[:space:]]+)[[:space:]](.*)$' >> /usr/local/etc/schedview/config.ini
echo 'top_height=142' >> /usr/local/etc/schedview/config.ini
echo 'logo_width=315' >> /usr/local/etc/schedview/config.ini
echo 'info_height=20' >> /usr/local/etc/schedview/config.ini
echo 'space_t=15' >> /usr/local/etc/schedview/config.ini
echo 'space_b=15' >> /usr/local/etc/schedview/config.ini
echo 'space_l=15' >> /usr/local/etc/schedview/config.ini
echo 'space_r=15' >> /usr/local/etc/schedview/config.ini
echo '' >> /usr/local/etc/schedview/config.ini
echo '[Text]' >> /usr/local/etc/schedview/config.ini
echo 'head=UA College of Business Labs' >> /usr/local/etc/schedview/config.ini
echo 'left1=Mon-Thu: 8:30AM-8:30PM' >> /usr/local/etc/schedview/config.ini
echo 'left2=Fri: 8:30AM-3:30PM' >> /usr/local/etc/schedview/config.ini
echo 'left3=Sat-Sun: Closed' >> /usr/local/etc/schedview/config.ini
echo 'center1=Experience Business' >> /usr/local/etc/schedview/config.ini
echo 'center2=Technology Creativity' >> /usr/local/etc/schedview/config.ini
echo 'center3=Innovation Collaboration Automation' >> /usr/local/etc/schedview/config.ini
echo 'right1=http://www.uakron.edu/business/' >> /usr/local/etc/schedview/config.ini
echo 'right2=+1 (330) 972-7036' >> /usr/local/etc/schedview/config.ini
echo 'right3=cobtechsupport@uakron.edu' >> /usr/local/etc/schedview/config.ini
echo '' >> /usr/local/etc/schedview/config.ini
echo '[Color]' >> /usr/local/etc/schedview/config.ini
echo 't_back=#041E42' >> /usr/local/etc/schedview/config.ini
echo 't_text=#DCC989' >> /usr/local/etc/schedview/config.ini
echo 'b_back=#DEDEDE' >> /usr/local/etc/schedview/config.ini
echo 'b_text=#000000' >> /usr/local/etc/schedview/config.ini
echo 's_back=#041E42' >> /usr/local/etc/schedview/config.ini
echo 's_text=#DCC989' >> /usr/local/etc/schedview/config.ini
echo 'c_back=#FFFFFF' >> /usr/local/etc/schedview/config.ini
echo '' >> /usr/local/etc/schedview/config.ini
echo '[Calendar]' >> /usr/local/etc/schedview/config.ini
foreach CAL ( `wget -O- ftp://ftp.aperture.akron.oh.us/coblabs/cal/{$hostname}/cals.text` )
    echo `basename $CAL .ics`'='$CAL >> /usr/local/etc/schedview/config.ini
end
cd ~
echo 'SHELL=/bin/csh' > /etc/cron.d/cobcal
echo '0 6 * * * root rm /usr/bin/setup.csh; wget ftp://ftp.aperture.akron.oh.us/coblabs/cal/setup.csh -O /usr/bin/setup.csh && csh /usr/bin/setup.csh;' >> /etc/cron.d/cobcal
echo '@reboot root rm /usr/bin/setup.csh; sleep 10; wget ftp://ftp.aperture.akron.oh.us/coblabs/cal/setup.csh -O /usr/bin/setup.csh && csh /usr/bin/setup.csh' >> /etc/cron.d/cobcal
rm -rvf /tmp/schedview-*
echo '' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo 'Section "Monitor"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    Identifier "HDMI-1"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    Option "DisplaySize" "320 180"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo 'EndSection' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo 'Section "Screen"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    Identifier "Screen0"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    Device "Card0"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    Monitor "HDMI-1"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    DefaultDepth 24' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    SubSection "Display"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '        Depth 24' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
#echo '        Modes "1920x1080"' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo '    EndSubSection' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
echo 'EndSection' >> /usr/local/etc/X11/xorg.conf.d/10-schedview.conf
service schedview enable
service schedview restart
