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
---
reddit-wallpaper-fetcher | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
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
--
Gitblit v1.10.0