Introducing daywall: a bash script to choose your wallpaper based on the time of day

I like computer wallpapers. To the point that the lack of icons on the desktop is a significant reason why I’m using Openbox as my window manager. I’ve got over 800 images I’ve chosen, ranging from scenic tilt-shift photography to fanart for some of my favorite shows.

With that many wallpapers, I’m a fan of utilities that rotate them.

But I also work nights, so suddenly having a bright sunny scene blasting my face at 0300 really kind of sucks.

So I decided to see if there was a single utility for the computer to figure out how bright the images were and then choose an appropriate one. I wanted to do so in a way that it didn’t really matter where or how the images were stored, that it’d deal with changing sunrise and sunset times, would add new images and remove deleted ones, and would allow me to use whatever tool I wanted to actually set the wallpaper.

There wasn’t, so I made one.

First, I had to figure out if such a thing was possible. Turns out, you can determine an image’s "brightness" with imagemagick. Here’s two proof of concept montages I created showing the range of brightnesses among my background images:


So then I found out how to get geolocation, times of sunrise and sunset, and did some math, and created daywall, a bash script to programatically select an appropriate wallpaper for what time of day it is.

daywall uses online geolocation to find your latitude and longitude, determine how far away from mid-day the current hour is, and then chooses a random image from the directory (or directories) you specify with a (calculated) brightness appropriate to the time of day.

See also  Getting the Weather And Forecast with A Bash Script

If you wish to make it darker, you can use the --darker switch, and it will create a darkened version in $TMP and output that file name for you.

By design, daywall does not set the wallpaper. It only returns the full pathname to an appropriate image. That allows you to (hopefully) use it with whatever flow you currently have in place. For example:

feh --bg-fill --no-xinerama $(daywall.sh)

You can read more about it and find daywall at GitHub, GitLab, or my personal git repository.

One thought on “Introducing daywall: a bash script to choose your wallpaper based on the time of day

Leave a Reply

Your email address will not be published. Required fields are marked *