aboutsummaryrefslogtreecommitdiff
path: root/i3
diff options
context:
space:
mode:
Diffstat (limited to 'i3')
-rwxr-xr-xi3/bin/setbg-backup3
-rwxr-xr-xi3/bin/setbg-cloogle9
-rwxr-xr-xi3/bin/setbg-pgfplots3
-rwxr-xr-xi3/bin/setbg-texample16
4 files changed, 10 insertions, 21 deletions
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 '^<dl' texample.html | wc -l)"
awk -v n=0 "BEGIN{srand();n=int(rand()*$EXAMPLES)+1} /^<dl/{l++} (l==n){print} END{}" texample.html | sponge texample.html
@@ -44,7 +35,6 @@ $CURL "http://texample.net$PDF" | convert -size "x$SCR_HEIGHT" -density 300 - /t
$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-page-0.png "/tmp/bg-$PAGE.png"
-rm /tmp/bg-{page-*,src}.png
-if [ $? -ne 0 ]; then fail; fi
+rm /tmp/bg-{page-*,src}.png || setbg-backup
feh -B white --bg-max "/tmp/bg-$PAGE.png"