From 510b99164956740f0f652705956f8f8bdac68027 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 13 Jun 2017 10:56:07 +0000 Subject: Fix setbg-texample for PDFs with more than 1 page --- i3/bin/setbg-texample | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'i3/bin') diff --git a/i3/bin/setbg-texample b/i3/bin/setbg-texample index bda60e2..c603bce 100755 --- a/i3/bin/setbg-texample +++ b/i3/bin/setbg-texample @@ -24,24 +24,27 @@ let "SCR_HEIGHT -= 2 * $PADDING" PAGE=$RANDOM; let "PAGE %= 22"; let "PAGE += 1" +echo "TeXample page: http://texample.net/tikz/examples/all/?page=$PAGE" + # Fetch list of texamples cd /tmp $CURL -o texample.html "http://texample.net/tikz/examples/all/?page=$PAGE" if [ $? -ne 0 ]; then fail; fi EXAMPLES="$(grep '^PDF<\/a>.*/\1/")" TEX="$(grep '\/media\/tikz\/examples\/TEX' texample.html | grep -v overleaf | sed "s/.*TEX<\/a>.*/\1/")" -echo $PDF $TEX +echo "PDF: $PDF" +echo "TeX: $TEX" -$CURL "http://texample.net$PDF" | convert -size "x$SCR_HEIGHT" -density 300 - /tmp/bg.png +$CURL "http://texample.net$PDF" | convert -size "x$SCR_HEIGHT" -density 300 - /tmp/bg-page-%d.png $CURL "http://texample.net$TEX" | sed -n '/\\begin{document}/,/\\end{document}/p' | pygmentize -l latex -O font_size=$FONT_SIZE -o /tmp/bg-src.png -montage -geometry "+$PADDING+$PADDING" /tmp/bg-src.png /tmp/bg.png "/tmp/bg-$PAGE.png" -rm /tmp/bg{,-src}.png +montage -geometry "+$PADDING+$PADDING" /tmp/bg-src.png /tmp/bg-page-0.png "/tmp/bg-$PAGE.png" +rm /tmp/bg-{page-*,src}.png if [ $? -ne 0 ]; then fail; fi feh -B white --bg-max "/tmp/bg-$PAGE.png" -- cgit v1.2.3