It’s sad to say this, but I’ve already begun to run out of viable wallpaper now that I can use fbterm to paint a background for my terminal systems. It’s sad only because over the years I’ve really only collected about eight or 10 that I consider worth keeping, and the rest have all gone the way of the delete key.
And using fbterm on the Celeron has added a curve ball to the way I usually do business around here. Not only is there quite a bit more screen space, and not only is that screen considerably larger than any other one in the house, but it’s a good display, clean and clear, and being able to use wallpaper on it means I like to tinker with a lot of different images. And those eight I saved are pretty much already boring.
What would be nice is to be able to yank an artistic or interesting image at random from somewhere on the web, crank down on the brightness so it’s suitable as a background to fbterm, and run through the entire business without having to repeat that over and over again, every time I turn on the machine.
Oh, but I never offer a problem without a solution. …
A couple of years ago I managed to hot-wire the Wikipedia Picture of the Day as a pipe menu for Openbox, using feh in its most popular function, background painter. And since the kind soul who creates the presized images of the POTD is still doing it, it’s just a short hop to automation.
There are lots of ways to do this; I’ll stick with wget and imagemagick; if you know of a lighter but as-versatile console image management tool, please speak up. First step is to grab that image off the web; this is the easy part.
wget -q http://toolserver.org/~daniel/potd/potd.php/commons/1024x768 -O $HOME/.potd.jpg
I want it in the same place every time, with a predictable and understandable name. The
q flag tells wget to be quiet, while the
-O lets me output to a different file name — this time, a dotted file name. I could just leave the file name as “1024×768″ but I have a tendency to go on wild deleting rampages, and calling it “.potd.jpg” keeps me from purging it out. Note that there are lots of different sizes to choose, including some common screen dimensions.
That was the easy part; this is the hard part: toning down the image so that it doesn’t render the text invisible.
convert -modulate 20,100,100 $HOME/.potd.jpg $HOME/.potd.jpg
Of course, every picture is going to be different. I picked 20 percent brightness because I figured too dark is better than too light. Feel free to adjust those numbers, if you dare.
After that, starting fbterm is really just a matter of jumping from one script to the next. There’s one small catch though: The script that appears in the man pages for fbterm suggests feeding the
k option to stretch the image to fit the screen, regardless of its dimensions.
But the POTD hosting site precrops the image to 1024 pixels across, and lets the depth fall free. That means a vertical image is going to be short and fat, rather than of natural dimensions.
The easiest way to solve that problem is to pull the
k flag out of the fbterm-bi script, since the image we pull is already the right dimension.
If you think that too simple, or if you have a screen with unusual dimensions, you’ll want to download the full image rather than the presized one, then ask imagemagick to crop it down to size.
convert -crop 1024x768 $HOME/.potd.jpg $HOME/.potd.jpg
This will scale it to the dimensions of a screen, starting at the upper left corner and catching only the available dimensions. Beyond that there’s not much I can suggest; you’ll have to get your hands dirty. Your screen of a different shape than mine (probably) and each picture that comes off the site is going to be of another shape.
And since the point here was to automate this as much as possible, I probably won’t worry if a picture is slightly stretched or off-cropped. Such is life. Tomorrow is a new day, and brings a new picture of the day.
In any case, the last line of your POTD script should feed the fbterm-bi script with the name of the image. And since the name and location are predictable …
And that should be the end. Collate, save and make executable with
chmod +x .scripts/fbterm-potd.sh. Copy-and-pasters, here’s the entire business in one small patch.
wget -q http://toolserver.org/~daniel/potd/potd.php/commons/1024x768 -O $HOME/.potd.jpg convert -modulate 20,100,100 $HOME/.potd.jpg $HOME/.potd.jpg $HOME/.scripts/fbterm-bi.sh $HOME/.potd.jpg
Don’t forget to trim the fbterm-bi script of that one character, and to make sure all these scripts are in the right place, or things won’t work quite right. Of course, you never get any guarantees from me anyway. …