.gitignore | ●●●●● patch | view | raw | blame | history | |
reddit-wallpaper-fetcher | ●●●●● patch | view | raw | blame | history | |
reddit-wallpaper-fetcher.conf | ●●●●● patch | view | raw | blame | history |
.gitignore
@@ -1,3 +1,4 @@ * !main.sh !reddit-wallpaper-fetcher !reddit-wallpaper-fetcher.conf !.gitignore reddit-wallpaper-fetcher
File was renamed from main.sh @@ -23,6 +23,9 @@ source $CONFDIR/reddit-wallpaper-fetcher.conf &>/dev/null #Loud output for testing a changed config [ -z "$1" ] && LOUD="-s" #Initialise time from last fetch LATEST_TIME=0 if [ -f $WALLDIR/json ]; then @@ -32,7 +35,7 @@ #Try subreddits for new images for i in "${SUBREDDITS[@]}"; do temp=$(curl -s --user-agent $USER "https://www.reddit.com/r/$i.json?sort=$SORT&limit=1") temp=$(curl $LOUD --user-agent $USER "https://www.reddit.com/r/$i.json?sort=$SORT&limit=1") time=$(echo $temp | jq ".data.children[-1].data.created_utc") if [ $(awk -v n1="$time" -v n2="$LATEST_TIME" 'BEGIN {printf (n1>n2?"1":"")}') ]; then LATEST=$temp @@ -48,7 +51,7 @@ #Download image url=$(echo $LATEST | jq ".data.children[-1].data.url" | sed 's/"//g') ext="$(echo $url | rev | cut -d'.' -f1 | rev)" curl -s -o "$WALLDIR/temp.$ext" "$url" curl $LOUD -o "$WALLDIR/temp.$ext" "$url" #Save image information echo $LATEST > $WALLDIR/json reddit-wallpaper-fetcher.conf
New file @@ -0,0 +1,16 @@ #List of subreddits to check SUBREDDITS=("Wallpapers") #What sort fetch list by, will choose the latest SORT=new #User-agent, shouldn't have to change USER=$(whoami) #Size of final image, currently unused SIZE=1920x1080 #Whether to write the title on the final image WRITE_TITLE=1 #Title color for ImageMagick TITLE_COLOR="white" #Title position for ImageMagick (North, South, East, West, Centre) TITLE_POSITION="Southeast" #Title font size TITLE_SIZE=30