blodgett solves a problem!

(with help of friend)

blodgett had a problem (but no longer): wanted wallpaper to change sometimes (blodgett likes variety), of its own accord (blodgett is lazy).

solution part 1: blodgett’s wallpapers are in a directory. blodgett runs fluxbox. blodgett will use fbsetbg! goes to manpage. friendly fbsetbg! it has already an option for random selection from a directory (-r). blodgett is pleased.

solution part 2: blodgett wants things to happen sometimes. blodgett acquires knowledge from friend of CRONTAB :O
running crontab -e opens a text file with mystifying markings. blodgett is mystified. acquires further knowledge from friend. fills out form. resembles now this:

# m h dom mon dow command
0,3,9,13,18,21,27,34,43,47,50,52,58 * * * * fbsetbg -r /home/blodgett/wallpaper/

the interpretation of which is to run command (fbsetbg …) at all listed minutes, of every hour, of every day of month, of every month, on every day of week. (hatching at start is for comment.)

so! crontab accept this input, blodgett wait in excitement for next listed minute! nothing happen. complain to friend. friend suggest maybe does not work when run without a display. friend further suggest solution of setting environment variable. this rather complicated for blodgett.

solution part 3: copy-paste friend knowledge into a file called bob. file bob resemble now:

#!/bin/sh

# I run this via a cron job where DISPLAY isn't set
if [ "$DISPLAY" = "" ]; then
DISPLAY=:0.0
fi

exec env DISPLAY=$DISPLAY fbsetbg -r /home/blodgett/wallpaper/

the interpretation of which is approximately to set a most likely display if it don’t know what to do, then run (exec) the fbsetbg thing with this informations (env, short for environment).

but! file is by default a file, not a program. cannot run a file. so must change mode (chmod) of bob to be executable.

solution part 4: run chmod +x bob

solution part 5: blodgett then updates the CRONTAB OF DOOM with new informations, which now resemble:

# m h dom mon dow command
0,3,9,13,18,21,27,34,43,47,50,52,58 * * * * /home/blodgett/bob

and wait for minute… and it work! blodgett have now randomly changing wallpapers! blodgett’s wallpapers have been upload here:
http://www.flickr.com/photos/blodgett-esq/sets/72157619470981253/

actually took blodgett longer to write this than to solve problem. blodgett bid you all good day, going for tea and cow biscuits now.

Leave a Reply