Skip to content

Instantly share code, notes, and snippets.

@airbornelamb
Created April 17, 2017 21:45
Show Gist options
  • Save airbornelamb/8a0f27e2e07b2da6534c3d4c67dd8c5f to your computer and use it in GitHub Desktop.
Save airbornelamb/8a0f27e2e07b2da6534c3d4c67dd8c5f to your computer and use it in GitHub Desktop.
Daily task emailer
#!/bin/bash
# Define your email address below
SENDTOEMAIL="[email protected]"
cd ~/Dropbox/agendamaker
FULLDATE=$(date +%A-%F)
FILEDATE=$(date +%F)
# JULIANDATE=$(date +%j)
~/bin/dropbox.py start
# Begin Creation of Side A
printf "\n" > ./tempSideA.txt
shuf -n 1 ./inputs/dailyversescurated.txt >> ./tempSideA.txt
printf "\n" >> ./tempSideA.txt
printf "\n < Prayers > \n\n" >> ./tempSideA.txt
grep '<' ./inputs/prayers.txt | tr -d '<' >> ./tempSideA.txt
cat ./inputs/today.txt >> ./tempSideA.txt
cat ./inputs/thisweek.txt >> ./tempSideA.txt
printf "\n[ Events Today ] \n\n" >> ./tempSideA.txt
BABYDUE=$(date -d 2may17 +%j)
NOWJULIAN=$(date +%j)
DAYSLEFT=$(expr $BABYDUE - $NOWJULIAN)
# printf "$DAYSLEFT days in the semester"
# printf $(( ( $(date -ud '2017-05-06' +'%s') - $(date -ud 'now' +'%s') )/60/60/24 )) >> ./tempSideA.txt
printf "$DAYSLEFT days until the baby comes \n" >> ./tempSideA.txt
curl http://tgftp.nws.noaa.gov/data/forecasts/zone/mi/miz057.txt | tr -d "\n\r" | grep -Eo 'TODAY.*TONIGHT' | sed -e 's/TODAY...//' -e 's/..TONIGHT//' >> ./tempSideA.txt
# curl http://tgftp.nws.noaa.gov/data/forecasts/zone/mi/miz057.txt | tr -d "\n\r" | grep -Eo 'TODAY...([^.]*\.){2}' | sed 's/TODAY...//' >> ./tempSideA.txt
# curl http://tgftp.nws.noaa.gov/data/forecasts/zone/mi/miz057.txt | tr -d "\n\r" | grep -Eo '([A-Z]* [A-Z]*|[A-Z]*)\.{3}([^.]*\.){3}' | head -n 3 >> ./tempSideA.txt
# curl http://tgftp.nws.noaa.gov/data/forecasts/zone/mi/miz057.txt | tr -d "\n\r" | grep -Eo 'TODAY...([^.]*\.){3}' >> ./tempSideA.txt
/usr/local/bin/gcalcli agenda --nocolor --detail_length --detail_location 12:01am 11:59pm >> ./tempSideA.txt
printf "\n[ Schoolwork ] \n" >> ./tempSideA.txt
task hideurg -paper -exam | grep -m 8 -E -i -v 'task|tasks' >> ./tempSideA.txt
printf "\n[ @Waiting ] \n\n" >> ./tempSideA.txt
grep '@' ~/Dropbox/todo/todo.txt >> ./tempSideA.txt
printf "\n[ Tasks ] \n\n" >> ./tempSideA.txt
~/Dropbox/todo/todo.sh -p list | grep -E -i -v 'TODO|--|\@'| sed 's/^..//' >> ./tempSideA.txt
# printf "\n[ Someday ] \n\n" >> ./tempSideA.txt
# shuf -n 1 ./inputs/someday.txt >> ./tempSideA.txt
# cat ./inputs/someday.txt >> ./tempSideA.txt
# cat ./inputs/footerquestion.txt >> ./tempSideA.txt
# Enscript and convert Side A
enscript --header=$FULLDATE tempSideA.txt -o - | ps2pdf - tempSideA.pdf
# enscript --no-header tempSideA.txt -o - | ps2pdf - tempSideA.pdf
# Begin Creation of Side B
printf "\n[ Agenda ] \n" > ./tempSideB.txt
DAYPLUSONE=$(date -d "+1 days" +%D)
DAYPLUSSIX=$(date -d "+6 days" +%D)
/usr/local/bin/gcalcli agenda $DAYPLUSONE $DAYPLUSSIX --nocolor --detail_length --detail_location >> ./tempSideB.txt
# printf "\n[ Overdue ] \n\n" >> ./tempSideB.txt
# task +OVERDUE list | sed 's/^.......//' | grep -E '222|413|432a|612|601|632a' >> ./tempSideB.txt
# printf "\n[ Next 7 Days ] \n\n" >> ./tempSideB.txt
# task +WEEK list | sed 's/^.......//' | grep -E '222|413|432a|612|601|632a' >> ./tempSideB.txt
printf "\n[ +paper ] \n" >> ./tempSideB.txt
task chrono +paper |grep -E -i -v 'task|tasks|--|due' >> ./tempSideB.txt
printf "\n[ +exam ] \n" >> ./tempSideB.txt
task chrono +exam |grep -E -i -v 'task|tasks|--|due' >> ./tempSideB.txt
# task +paper or +exam list | sed 's/^.......//' | grep -E '222|413|432a|612|601|632a' >> ./tempSideB.txt
printf "\n\n" >> ./tempSideB.txt
cal -A 2 >> ./tempSideB.txt
# curl wttr.in/49505 | sed -n '8,17p' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" >> ./tempSideB.txt
printf "\n" >> ./tempSideB.txt
cat ./inputs/events.txt >> ./tempSideB.txt
# cat ./inputs/footerquestion.txt >> ./tempSideB.txt
# Enscript and convert Side B
enscript --no-header tempSideB.txt -o - | ps2pdf - tempSideB.pdf
# Combine Side A and B into one PDF document and store it in folder
pdfunite tempSideA.pdf tempSideB.pdf ./briefs/$FILEDATE.pdf
# pdfunite tempSideA.pdf tempSideB.pdf ./extrapages/grid1.pdf ./briefs/$FILEDATE.pdf
# Email everything
mpack -s $FILEDATE ./briefs/$FILEDATE.pdf $SENDTOEMAIL
# (uuencode $FILEDATE.pdf $FILEDATE.pdf; uuencode tempSideA.pdf tempSideA.pdf) | mail -s "multiple attachments" [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment