Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fpgaminer
Created November 7, 2016 03:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fpgaminer/bdd493ce84eafb7886e08d20c27b0077 to your computer and use it in GitHub Desktop.
Save fpgaminer/bdd493ce84eafb7886e08d20c27b0077 to your computer and use it in GitHub Desktop.
Downloads a random image from Unsplash and sets the wallpaper every so often (currently only works with Gnome/Unity/Cinnamon/etc)
#!/bin/sh
while :
do
wget -q -O unsplash_wallpaper.jpg https://unsplash.it/1920/1080/?random
gsettings set org.gnome.desktop.background picture-uri file://$PWD/unsplash_wallpaper.jpg
sleep 1h # Change this if you want a different update frequency (e.g. 30m, 12h, 24h, etc...).
done
@kinduff
Copy link

kinduff commented Nov 7, 2016

Here's for OSX.

#!/bin/sh

while :
do
	wget -q -O unsplash_wallpaper.jpg https://unsplash.it/1920/1080/?random
        osascript -e 'tell application "Finder" to set desktop picture to POSIX file "$PWD/unsplash_wallpaper.jpg"'	
	sleep 1h
done

If you want curl instead just replace the wget line.

curl -o unsplash_wallpaper.jpg https://unsplash.it/1920/1080/?random

@jjaimealeman
Copy link

jjaimealeman commented Oct 17, 2021

I found this page after searching earlier today. I decided to your your idea and came up with this:

#!/bin/bash

function unsplash {
    local FILENAME=unsplash-$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 10;echo)
    wget -q -O $FILENAME.jpg https://unsplash.it/1920/1080/?random
    echo $FILENAME.jpg
    convert -geometry 450x $FILENAME.jpg $FILENAME-450w.jpg
    convert -geometry 800x $FILENAME.jpg $FILENAME-800w.jpg
}
unsplash

Generates 3 random files.

  • unsplash-RANDOMUUID.jpg
  • unsplash-RANDOMUUID-450w.jpg
  • unsplash-RANDOMUUID-800w.jpg

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment