K.Mandla's blog of Linux experiences

Browse and set wallpaper in Openbox with feh

Pretty much since I started using Openbox, I’ve been wanting a simple way to change the wallpaper from the right-click menu. I eventually found a way, using a script that reads my wallpaper directory and lists files it finds there. Clicking on the menu entry triggers feh, which sets the image to the root window. It’s not ideal, since really I don’t remember what some of those wallpapers look like, and the names aren’t obvious choices. But it’s a simple solution, even if it wasn’t so simple to figure out.

At the same time, I’ve been grinding my teeth over the fact that Ubuntu’s version of Mirage, a nifty GTK image viewer with only one dependency, is saddled with an inordinate amount of optional Gnome baggage. I could use a decent image viewer to screen photos … and sift through my wallpaper folder, to be honest. With Mirage so burdened, I wasn’t keen on auditioning more image viewers.

And then today, about an hour ago, the two puzzle pieces suddenly clicked. I was running Midnight Commander in a terminal emulator and double-clicked on a photo. Boing! Up pops feh, showing me the full image, with a bunch of right-click menu options — including setting the image as the background!

Doh! Of course! feh is an image viewer! Here’s the lightweight customizable command-line-triggerable imageviewer that I’ve been looking for … for months! I only ever install it to set the wallpaper, and it’s something I’ve been using since I started out with Openbox. But that’s just a bonus, an added little something on top of the image slideshow, indexing and montage/collage effects it offers.

I feel like someone punched me in the stomach. All this time and it was right under my nose. :|

So anyway, add this line to an Openbox menu for a pop-up feh window that will let you peruse through a folder of images — of almost any type — and set one to the background through a right-click menu.

feh -g 640x480 -d -S filename /home/kmandla/wallpaper/

The -g option keeps the previews within 640×480, while the -d option shows the filename over the photo, in case you’re keeping track. -S sorts them by filename, and there are other options than that. Change you folder location to match your machine, and while you’re at it you might double-check the other feh options that are available to you. There are a LOT.

Right now I’m going to go kick myself repeatedly, for waiting almost a year to spend the 10 minutes it took to figure this out. :evil: