From aed5a8427e40127a18f2f2899776b85b46f0b97a Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Sat, 05 Dec 2020 12:08:10 +0000
Subject: [PATCH] Added conf and renamed files, allowed loud running

---
 .gitignore                    |    3 ++-
 reddit-wallpaper-fetcher      |    7 +++++--
 reddit-wallpaper-fetcher.conf |   16 ++++++++++++++++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index c05844f..894d5ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 *
-!main.sh
+!reddit-wallpaper-fetcher
+!reddit-wallpaper-fetcher.conf
 !.gitignore
diff --git a/main.sh b/reddit-wallpaper-fetcher
similarity index 88%
rename from main.sh
rename to reddit-wallpaper-fetcher
index b979730..f01551b 100755
--- a/main.sh
+++ b/reddit-wallpaper-fetcher
@@ -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
diff --git a/reddit-wallpaper-fetcher.conf b/reddit-wallpaper-fetcher.conf
new file mode 100644
index 0000000..2b40c9a
--- /dev/null
+++ b/reddit-wallpaper-fetcher.conf
@@ -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

--
Gitblit v1.10.0