> Nathan's notes_ Search Rice Projects Reading Root

Creation of a time based wallpaper with feh

17 February 2014

One of the most popular posts of all time over in /r/wallpapers is an album set of 8 8-bit landscapes for every time of day. Here is a quick glimpse:

 

[caption id="" align="aligncenter" width="1152"] summary picture![/caption]

If you use feh to manage you background, the current background filename is stored in ~/.fehbg. If you name each picture in the 8 picture set 01 - 09, you can easily set an appropriate picture to the time of day.

Here is the bash script I am currently using to do this:

imagepath="/home/neeasade/images/8bitday";
while :
do
if echo 0$(expr $(date +%H) / 3).png != cat /home/neeasade/.fehbg | egrep '[0-9]{2}.png'; then
feh --bg-fill $imagepath/0$(expr $(date +%H) / 3).png;
fi
sleep 5
done

The above while runs forever, checking the name of the current background picture at an interval of 5 seconds. Since there are 8 pictures in the total group, you can take the current hour of the day(out of 24) divided by 3 using integer division. running this in the background on startup as been giving me a nice wallpaper to match the time of day!