konachan-wallpaper/updateWallpaper.sh
2016-09-11 16:31:50 +02:00

24 lines
569 B
Bash
Executable File

#!/bin/bash
tag="scenic"
picdir=`realpath $(dirname "${BASH_SOURCE[0]}")`
while [ 0 ]; do
json=`curl "http://konachan.com/post.json?tags=$tag%20order:random%20width:1600&limit=1"`
id=`echo $json | jq -r '.[0].id'`
url=`echo $json | jq -r '.[0].file_url'`
ext=`echo $url | sed "s/.*\.//g"`
local_url="$picdir/$id.$ext"
if [ -f "$local_url" ]; then
echo "Already set as wallpaper. Waiting for new one..."
else
echo "Updating wallpaper!"
curl -o "$local_url" "$url"
fi
gsettings set org.gnome.desktop.background picture-uri "$local_url"
sleep 1h
done