Created
April 7, 2019 06:37
-
-
Save lesliesrussell/37c6608bb51878c09695da7c9838202f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OUTFILE=$(mktemp --suffix=.tex) | |
BASE_DATE=$(date --date=now +%Y-%m) | |
RED_LETTER_DAY=$(date --date=now +%F) | |
ORIGWAL=$(cat ~/.cache/wal/wal) | |
CAL_COLOR=$(xrdb -query | grep *.color66 | awk -F# '{print $2}') | |
# ----------------------------------------------------------- | |
# 'Here document containing the body of the generated script. | |
( | |
cat <<EOF | |
\documentclass[convert={density=300,size=300x300,outext=.png}]{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{calendar} | |
\begin{document} | |
\color[HTML]{$CAL_COLOR} | |
\begin{tikzpicture} | |
\calendar (mycal) [dates=$BASE_DATE-01 to $BASE_DATE-last,week list]; | |
\draw[red] (mycal-$RED_LETTER_DAY) circle (4pt); | |
\end{tikzpicture} | |
\end{document} | |
EOF | |
) > $OUTFILE | |
# ----------------------------------------------------------- | |
pdf2png () { | |
cd /tmp | |
pdflatex -shell-escape $OUTFILE | |
PNGOUT=$(echo $OUTFILE | sed 's/tex/png/g') | |
convert $ORIGWAL $PNGOUT -gravity SouthEast -composite -format png -quality 90 output.png | |
DEL_TMPS=$(echo $OUTFILE | sed 's/tex/\*/g') | |
rm $DEL_TMPS | |
} | |
pdf2png | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment