#!/bin/sh

OUTPUT_FILE=~/org/ical.org


while read cal ; do
    URL=$(echo $cal | awk -e '{print $1}')
    OUT=$(echo $cal | awk -e '{print $2}')
    OUT=${OUT:-${OUTPUT_FILE}}
    TEMP=$(mktemp)
    wget $URL -O "${TEMP}"
    ical2org-awk "${TEMP}" "${OUT}"
    rm "${TEMP}"
done <~/.dotfiles/ical.txt

cd ~/org || exit 1
git add ical.org
git commit -m "Pulled ical files"
