diff --git a/.local/share/scripts/random-bg.sh b/.local/share/scripts/random-bg.sh new file mode 100755 index 0000000..17140f4 --- /dev/null +++ b/.local/share/scripts/random-bg.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +$SCRIPTPATH/set-bg.sh $(shuf -n1 -e ~/pictures/wallpapers/*) diff --git a/.local/share/scripts/reddit-wp.sh b/.local/share/scripts/reddit-wp.sh new file mode 100755 index 0000000..069c4bb --- /dev/null +++ b/.local/share/scripts/reddit-wp.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +# required packages: +# - wget +# - jq + +set -e + +#wget -O - http://www.reddit.com/r/wallpapers.rss 2> /dev/null | grep -Eo "https://?[^&]+(jpg|png)" | grep -v "thumbs" | head -1 +wget -O - "http://www.reddit.com/r/wallpapers/top/.json?t=day" 2> /dev/null | jq -r ".data.children[0].data.url" diff --git a/.local/share/scripts/select-bg.sh b/.local/share/scripts/select-bg.sh new file mode 100755 index 0000000..91afc24 --- /dev/null +++ b/.local/share/scripts/select-bg.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +# required packages: +# - sxiv + +SELECT=$(sxiv -N "floatme" -t -o ~/pictures/wallpapers | tail -n1 ) +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +$SCRIPTPATH/set-bg.sh "$SELECT" + diff --git a/.local/share/scripts/set-bg.sh b/.local/share/scripts/set-bg.sh new file mode 100755 index 0000000..8e232c5 --- /dev/null +++ b/.local/share/scripts/set-bg.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env sh +# required packages: +# - feh + +set -e + +[ -z "$@" ] && exit 0 + +LAST_BG_LOCATION="$XDG_CACHE_HOME/.last-bg" + +feh --bg-scale $1 + +rm -f "$LAST_BG_LOCATION" +ln -s $1 $(realpath "$LAST_BG_LOCATION") + diff --git a/.local/share/scripts/set-reddit-bg.sh b/.local/share/scripts/set-reddit-bg.sh new file mode 100755 index 0000000..96499c9 --- /dev/null +++ b/.local/share/scripts/set-reddit-bg.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +URL=$($SCRIPTPATH/reddit-wp.sh) +NAME=$(basename "$URL") +FILENAME=~/pictures/wallpapers/"$NAME" +wget "$URL" -nc -O "$FILENAME" +sleep 1 +$SCRIPTPATH/set-bg.sh $FILENAME +