Unsplash wallpaper downloader
#1
Hi all,

I really love this skin and I liked the wallpapers that were already available but I thought it'd be cool to download some others at a specified period so i created a bash script that does exactly that (sort of).

bash:

#/bin/bash

name=wallpaper
if -e $name.jpg (wiki) ; then
    i=0
    while -e $name-$i.jpg (wiki) ; do
        let i++
    done
    name=$name-$i
fi
touch "$name".jpg

wget -O "$name".jpg https://unsplash.it/1920/1080/?random

Save this to a file "myscript.sh"

Then open a command prompt and make it executable

Code:
chmod +x myscript.sh

copy the file to the path with all the pellucid wallpapers (I'm using openelec): /storage/.kodi/addons/skin.pellucid/extras/homeBackgrounds/

Then use crontab to run the script at a specified interval. You *could* put a sleep command in the script but that's a bit rubbish...

Open a command prompt and ssh in to the kodi box

ssh root@IP_OF_KODI
password: openelec

Type "crontab -e" and press Enter

My input is 9am every day of every month of every year:

0 9 * * * /storage/.kodi/addons/skin.pellucid/extras/homeBackgrounds/myscript

Ctrl+O to save and Enter to confirm

Ctrl+X to exit.

That's it! It'll download a new wallpaper every day to add to your collection. It will do that forever so maybe I'll add a "delete oldest image" after a set time too. But this is enough for me now.

Let me know your thoughts,
Cheers.
Reply
#2
Good idea! I got an error, though. When trying to run the script manually, I got the error "unsplash.sh: line 4: syntax error: unexpected "(" (expecting "then")"

I'm using Libreelec, but can't imagine that's the issue.
Reply
#3
(2019-11-28, 13:11)cat0 Wrote: Good idea! I got an error, though. When trying to run the script manually, I got the error "unsplash.sh: line 4: syntax error: unexpected "(" (expecting "then")"

I'm using Libreelec, but can't imagine that's the issue.
pff! sorry, forum formatting error...

if -e $name.jpg (wiki) ; then
    i=0
    while -e $name-$i.jpg (wiki) ; do
        let i++
    done
    name=$name-$i
fi
touch "$name".jpg

You shouldn't have any issue on libreelec.
Reply
#4
(2019-11-28, 23:13)davbren Wrote:
(2019-11-28, 13:11)cat0 Wrote: Good idea! I got an error, though. When trying to run the script manually, I got the error "unsplash.sh: line 4: syntax error: unexpected "(" (expecting "then")"

I'm using Libreelec, but can't imagine that's the issue.
pff! sorry, forum formatting error...

if -e $name.jpg (wiki) ; then
    i=0
    while -e $name-$i.jpg (wiki) ; do
        let i++
    done
    name=$name-$i
fi
touch "$name".jpg

You shouldn't have any issue on libreelec. 
Gahd! ummmmmm, let me link to it from gdrive...

here
Reply
#5
aaaand it works perfectly. Thanks! Smile
Reply
#6
(2019-11-29, 19:28)cat0 Wrote: aaaand it works perfectly. Thanks! Smile

Great! Let me know if you think of improvements or any cool things you'd like to see.
Reply

Logout Mark Read Team Forum Stats Members Help
Unsplash wallpaper downloader1