From d7ac1726781db42393676974e0dbf002998112f4 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 15 Dec 2017 14:43:37 +0100 Subject: Add setbg-backup with support for randomising a background image --- i3/bin/setbg-backup | 3 +++ i3/bin/setbg-cloogle | 9 +-------- i3/bin/setbg-pgfplots | 3 +++ i3/bin/setbg-texample | 16 +++------------- 4 files changed, 10 insertions(+), 21 deletions(-) create mode 100755 i3/bin/setbg-backup diff --git a/i3/bin/setbg-backup b/i3/bin/setbg-backup new file mode 100755 index 0000000..d70f7f4 --- /dev/null +++ b/i3/bin/setbg-backup @@ -0,0 +1,3 @@ +#!/bin/bash + +feh --bg-fill "$(ls -1 ~/.bg.*.{jpg,png} | sort -R | head -1)" diff --git a/i3/bin/setbg-cloogle b/i3/bin/setbg-cloogle index 64c3316..97e8154 100755 --- a/i3/bin/setbg-cloogle +++ b/i3/bin/setbg-cloogle @@ -1,14 +1,7 @@ #!/bin/bash -function fail() { - if [ -f ~/.bg.png ]; then - feh --bg-max -B white ~/.bg.png - fi - exit -1; -} - # Test internet -timeout 4 wget -q --spider http://cloogle.org || fail +timeout 4 wget -q --spider http://cloogle.org || setbg-backup stdbuf -i0 -o0 -e0 cloogle_stats.py | while read request do diff --git a/i3/bin/setbg-pgfplots b/i3/bin/setbg-pgfplots index 7343f35..1479844 100755 --- a/i3/bin/setbg-pgfplots +++ b/i3/bin/setbg-pgfplots @@ -12,6 +12,9 @@ let "SCR_HEIGHT -= 2 * $PADDING" NR=$RANDOM let "NR %= 524" +# Test internet +timeout 4 wget -q --spider http://cloogle.org || setbg-backup + wget -qO- "http://pgfplots.sourceforge.net/example_$NR.pdf" | convert -size "x$SCR_HEIGHT" -density 300 - /tmp/bg.png wget -qO- "http://pgfplots.sourceforge.net/gallery.html" | sed -n "/example_$NR\.pdf/,/<\/div>/p" | tail -n +6 | head -n -1 | pygmentize -l latex -O font_size=$FONT_SIZE -o /tmp/bg-src.png diff --git a/i3/bin/setbg-texample b/i3/bin/setbg-texample index c603bce..610c54f 100755 --- a/i3/bin/setbg-texample +++ b/i3/bin/setbg-texample @@ -7,16 +7,8 @@ FONT_SIZE=20 CURL="curl -s" -function fail() { - if [ -f ~/.bg.png ]; then - feh --bg-max -B white ~/.bg.png - fi - exit -1; -} - # Test internet -timeout 4 wget -q --spider http://texample.net -if [ $? -ne 0 ]; then fail; fi +timeout 4 wget -q --spider http://texample.net || setbg-backup let "SCR_WIDTH -= 2 * $PADDING" let "SCR_WIDTH /= 2" @@ -28,8 +20,7 @@ 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 +$CURL -o texample.html "http://texample.net/tikz/examples/all/?page=$PAGE" || setbg-backup EXAMPLES="$(grep '^