diff options
author | Camil Staps | 2016-04-08 10:42:37 +0200 |
---|---|---|
committer | Camil Staps | 2016-11-30 19:11:42 +0100 |
commit | c966a7bb95242f5a53ff161b53ac8dab56eba012 (patch) | |
tree | b03cad38dc7185b97300b15f8850a7b7f7175449 /bin/setbg-texample | |
parent | TeXample background (diff) |
Reorganised bg stuff
Diffstat (limited to 'bin/setbg-texample')
-rwxr-xr-x | bin/setbg-texample | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/setbg-texample b/bin/setbg-texample new file mode 100755 index 0000000..3721944 --- /dev/null +++ b/bin/setbg-texample @@ -0,0 +1,29 @@ +#!/bin/bash + +SCR_WIDTH=1980 +SCR_HEIGHT=1080 +PADDING=50 +FONT_SIZE=20 + +let "SCR_WIDTH -= 2 * $PADDING" +let "SCR_WIDTH /= 2" +let "SCR_HEIGHT -= 2 * $PADDING" + +PAGE=$RANDOM; let "PAGE %= 22"; let "PAGE += 1" + +cd /tmp +wget -qO texample.html "http://texample.net/tikz/examples/all/?page=$PAGE" +EXAMPLES="$(grep '^<dl' texample.html | wc -l)" +awk -v n=0 "BEGIN{n=int(rand()*$EXAMPLES)} /^<dl/{l++} (l==n){print} END{}" texample.html | sponge texample.html + +PDF="$(grep '\/media\/tikz\/examples\/PDF' texample.html | sed "s/.*<a href=\"\([^\"]*\)\">PDF<\/a>.*/\1/")" +TEX="$(grep '\/media\/tikz\/examples\/TEX' texample.html | grep -v writelatex | sed "s/.*<a href=\"\(.*\)\">TEX<\/a>.*/\1/")" + +wget -qO- "http://texample.net$PDF" | convert -size "x$SCR_HEIGHT" -density 300 - /tmp/bg.png +wget -qO- "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 + +feh -B white --bg-max "/tmp/bg-$PAGE.png" + |