Cron, Backgrounds, and Fluxbox
Honest to God, I spent so much time getting this blog, domain, etc. up, that I almost forgot what spurred me to get started. So here’s why… I had this problem. Rather, not so much a problem as a desire to rotate my backgrounds periodically. Let’s say… every 2 hours. Now, a guy like me, I think “cron!” This is the first thought of any veteran Linux user. However, I quickly came to the realization that I didn’t know quite how or where to put my cron entries, nor what format. This problem was, however, quickly remedied. That was not my problem.
The true problem arose when I attempted to actually implement changing my background. With fluxbox, this should be possible with a simple command like so:
fbsetbg -a -r /home/dfego/.fluxbox/backgrounds/
Simple enough, right? Well, as simple as it was, it just didn’t quite work. So I changed my cron timings, in case I got that wrong then used absolute paths, once again, just in case. Freaked out for a while, because the command itself works just fine. I ran it from a terminal about 29,834 times to make sure, but still, that little cron daemon that could just wouldn’t budge. It would, however, write the text “working” into ~/cronf*cker every minute. As a matter of fact, it still is. Allow me to go take care of that…
Now that that’s taken care of, I’ll go ahead and tell you what the real problem was. Apparently the cron daemon doesn’t have any inherent knowledge of the X display server I want to set the background of. Fair enough, since it starts running well before X gets started. But I didn’t realize this would matter, or even think about it at all until I saw a post online about setting fluxbox backgrounds in a more general sense. It proposed butting DISPLAY=:0.0 before the line, like so:
DISPLAY=:0.0 fbsetbg -a -r /home/dfego/.fluxbox/backgrounds/
I changed the file, bit my lip, and a second or so after the next minute passed, my background was changed anew! As a note, my X server is not using display :0.0, but rather :1.0. You can find out what your value is by opening up a terminal and typing:
echo $DISPLAY
Anyway, there you have it. My first pearl of wisdom to the world! Apologies for verbosity, but sometimes in explanations such as this, it helps. So the moral of the story/digest version: be aware of context when running commands for X! Or something like that. I actually was at work today trying to impress a co-worker of mine with the power of the command line, but unfortunately my attempt fell flat on its face when passing commands to xmessage. I’m not too worried about it though. My ping/grep antics seemed to be enough to win him over.
With that, I’m off to bed, and to watch my background change once more before daybreak!