LinkedIn Sourceforge

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

Refresh the desktop background with unsplash pictures

Posted on 2019-01-27 18:17:00 from Vincent in OpenBSD Desktop

On the unsplash website we can find lot of very nice pictures. Moreover they have a permissive license (check the unsplash license).

I share a very simple script allowing you to refresh your desktop's background at each logon, or when you want


For those who don't know allow you to use and modify freely their pictures.
If you don't know it, please check their license model

Thanks to heir API, we can download pictures base on keywords.

Basically, you can download a picture with the following URL:$QUERY

Where $QUERY will be a keyword, or a list of keywords separated by a comma.

Examples are:,water

An interesting feature from unsplash, is that you can specific the size of the picture you want. The file you will get, will have the size you have selected. To do that, you just have to replace "featured" by the size you want:,water

Change your desktop's background

To easily change the background, I propose to use feh

feh --bg-max $IMG_PATH

Where $IMG_PATH point to the image you want to display

Glueing all together

Putting all those elements together, you have a very simple script like this:


QUERY=wallpaper            #comma separated words
[ "$1" ] && QUERY=$1
RESO=$(/usr/X11R6/bin/xrandr | awk '$2~/\*/ {print $1}')
if [ -f /usr/local/bin/feh ]
    /usr/bin/ftp -MV -o $IMG_PATH$RESO/?$QUERY 
    /usr/local/bin/feh --bg-max $IMG_PATH
    echo Error !!!!
    echo You have to install feh: doas pkg_add feh
    exit 1

Let's call this script ""

For info, the "ftp" command of this script, is the one of OpenBSD. If you want to use this on other OS, I think you could replace this ftp command by a curl command. But the parameters must be adapted too.

Without argument, this script will search one picture in the "wallpaper" category. But you can select other one if you want: moon nature,water

Integration in Openbox

If you are like me an happy user of OpenBOX, I propose you to call this script from your script (~/.config/openbox/

Very simple script, but pleasant results

28, 28
displayed: 4987

What is the second letter of the word Moon?