Sunday, July 31, 2016

How To: Change your desktop background in BSPWM

Howdy! So, you've installed bspwm and you noticed that it's not as fancy as what you're used to. No fancy settings for changing your desktop environment, no 'settings', nothing. We're left to our own devices.

Thankfully, Linux is full of devices for us to use. One of which, feh, will let us change what wallpaper is used by bspwm.

Install feh

The first step is to install feh. Feh is small program used to view images without using a ton of resources. Luckily, feh has been adapted to work as a background setter.

    sudo apt-get install feh
    sudo dnf install feh
    sudo pacman -S feh

Use Feh
In order to simply use feh as a photo viewer, you can call "feh picture.jpg", where "picture.jpg" is any image file that ImageMagick can open. In order to use feh to create a desktop background, call this command:

feh --bg-center picture.jpg
Once again, where picture.jpg is just about any image file.

And there you have it! A desktop background... for now. The thing is, after this session, the background will revert to normal. In case you want this to remain your desktop background, we need to edit out bspwmrc file.

Configure feh
 In your bspwmrc file, which is usually located in ~/.config/bspwm/bspwmrc, we need to call feh on startup. On mostly any line, preferably towards the end of the file, add this line:
feh --bg-center ~/Pictures/background.jpg
where the filepath is the path to the file you plan to use for your background. Now, when you start bspwm, it should set up the background for you automatically.

Further Configuration

Now, there are further ways that you can configure feh. Right now it's set to center the image in the middle of the desktop, surrounding it with a black border. If you'd prefer to have it stretch, or tile, you can use these flags in place of --bg-center:

--bg-fill : This will preserve the aspect ratio of the file, and optionally cut off whatever part of the image doesn't scale.

--bg-max : this will scale the image to its maximum size, and put black borders on one side.

--bg-scale : Will distort the image to fit exactly within the confines of the desktop. Since this doesn't preserve the aspect ratio, stretching may be a result.

--bg-tile : Will repeat the image until it fits within the monitor.

Advanced Configuration
So, now you know how to get the desktop set up in bspwm. But, bspwm "configurability" is a bit more than your average configurability. We can do some pretty cool stuff with the fact that we're using a shell to set the desktop background.

How about instead of the earlier command, we put this in the configuration file:

feh --bg-center $(find ~/Pictures/Backgrounds -type f | shuf -n 1)
So that it randomly chooses a background out of a "Backgrounds" folder in your Pictures directory?

Anything like this is possible in bspwm. You can have it change based on the time of day, or the type of music playing, or... anything really. The choice is always yours with BSPWM!

No comments:

Post a Comment