scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit e162aee69ecc11ba4008a746c877a80acb40ae2b
parent f8ef12d4c4747773e838b7585d005fa2fd4474e4
Author: clamiax <smoppy@gmail.com>
Date:   Mon,  6 Jan 2014 10:49:31 +0000

Allow to specify sources via command line (multiple -s flag).

Diffstat:
Mscrapthumb | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/scrapthumb b/scrapthumb @@ -11,7 +11,7 @@ MAXIMGS=5 RANDOMIZE=0 # No trailing slash -SOURCES=( +DEF_SOURCES=( "http://desktopwallpaperproject.tumblr.com" "http://wallpapermag.tumblr.com" "http://hdwallpaper.1nation.eu" @@ -21,7 +21,9 @@ SOURCES=( # Do not edit below. ## +SOURCES=() IMGS=() + preload() { s=0 for i in $(seq 0 $(echo $MAXIMGS - 1|bc)) @@ -35,7 +37,7 @@ preload() { src=${SOURCES[$s]} - [ $s -ge ${#SOURCES[*]} ] && s=0 + [ $s -ge ${#SOURCES[@]} ] && s=0 IMGS[$i]="$($GETTER "$src/random" |grep -o 'property="og:image" content=".*"' |cut -b 29- |tr -d \")" done } @@ -55,11 +57,18 @@ main() { case $opt in h) usage;; n) MAXIMGS=$OPTARG;; - s) SOURCES=($OPTARG);; + s) + i=${#SOURCES[*]} + SOURCES[$i]=$OPTARG;; r) RANDOMIZE=1;; esac done + [ ${#SOURCES[*]} -eq 0 ] && SOURCES=${DEF_SOURCES[@]} + + echo ${SOURCES[*]} + exit 0 + preload $VIEWER ${IMGS[*]} }