i3wm is a tiling window manager that is powerful and resource efficient. It is used by many geeks who prefer more resources for their computers. I personally use it when I need to fire up virtualization software so my computer will have sufficient RAM for the guest OS.
Unfortunately, i3wm doesn’t provide a way/tool to set up wallpapers on our beloved computers. A fresh install of this window manager would leave us a black screen and an i3status at the bottom. Luckily today, you’ll be relieved to know that it’s possible to set wallpapers using a cool utility and lightweight program called feh.
feh is an image viewing program but it is also used as a wallpaper setting program for our case. It is lightweight and command-oriented so it’s not intended for ordinary GUI-savvy users.
If you haven’t installed the program yet, launch the terminal and key in the below command to install feh on your computer.sudo apt install fehI’m assuming you’re following this article on Ubuntu machine or on any Debian-based Linux OS.
First, we’ll see how to set an image as a static wallpaper on i3wm. I’m considering you already have a login manager program like lightdm, gdm, etc where you enter your username and password to login to your account. We’ll be editing a file called .profile in your account’s home directory. This file .profile is what your computer loads and executes when you successfully log in to your account, so generally speaking you can input more custom commands if you like to automate your work. And now we have a need to automate setting background wallpaper when i3wm starts up.
Launch your favorite text editor program and open ~/.profile file.
Add the following commands on the last line to execute feh when you successfully log in to your account. feh –bg-fill ~/Pictures/Sample_picture.jpg The directory for your image may vary but you already get the point 🙂
But what if you prefer feh loading a random wallpaper from within a directory every time you log in? This is more dramatic and refreshing as you get to enjoy different wallpapers (automatically) without having to change the command manually.
Below is a refined feh command to enable randomization when feh loads up a wallpaper for your current session:
feh --randomize --bg-fill ~/Pictures/*
Now comes the dynamic!
My first Linux distro Linux Mint Cinnamon had a wallpaper setting where I can enable random wallpapers every specific interval of time. That made my desktop look fresher and kept me quite mesmerized when I closed down all the apps to enjoy a new wallpaper scene. That functionality is also possible on i3wm but again it’ll be command-oriented 😉 And there are just too many possible ways to count the time interval before switching a new wallpaper.
However, for this article, we’ll be focusing on watch utility program. Again below is a more refined command to enable randomization and change wallpaper scene every twenty minutes. watch -n 1200 feh –randomize –bg-fill ~/Pictures/*
If you are confused with the number 1200, it’s in seconds so divide it by 60 (seconds) and you’ll get 20 minutes. But what if you prefer a shorter duration say 15 minutes? Simple, fire up your calculator and multiply your required time duration number with 60.
So we have 15 x 60 = 900.
And replacing 1200 with this new time duration will give us the below-customized commandwatch -n 900 feh –randomize –bg-fill ~/Pictures/*
There’ll be some geeks who don’t prefer a login manager program like lightdm or gdm but a bare terminal session and when necessary execute startx command to load his/her GUI session. In such configuration, editing .profile won’t be a solution but instead cause problematic issues because feh requires a working X11 session and your environment is otherwise.
The solution to this is to create a new file called .xsession in your account home directory and append all the step by step commands to successfully start an i3wm session. For instance: watch -n 1200 feh –randomize –bg-fill ~/Pictures/* &
# more commands and then finally your window manager
There you go. I hope this article has been helpful in eradicating a common issue you encountered with i3wm. By the way, there are more cool tricks with this window manager such as theming its window looks and feel, setting keyboard shortcuts, customizing i3status, etc. Hopefully, in my next article, I’ll be writing about how to beautify i3 program windows ie., look and feel. Please do share your views and opinions in the comment section below. I’d be glad to read them 🙂
There is a simpler way to run the feh command for i3 at startup. For a simple once-per-session background, run the feh command that you want to use at least once on your normal command line, then put the below command in your i3 config file.
exec –no-startup-id ~/.fehbg
Feh automatically saves the background command last used in this file (unless you specifically disable that as listed in the man page).
For a more complicated background set procedure, create a script (named other than ~/.fehbg) to set the background however you want. Test the script so that you know it works, then add the below line instead of the other one mentioned above somewhere in the i3 config file.
exec –no-startup-id /path/to/your/script
Depending on what your script does, you may want to send it to background by adding a space and ampersand (&) to the end.
I’m really surprised, watch command is not to be used this way. You better write some script for this. This is not a way to go.
i found that when editing my .profile it gave an error message and it didn’t change or set my background. i had to fix my .profile and i could finally set a static background again. if there’s any way to do it in the i3 config it would be great as I can’t seem to get the watch command to work in i3 config. i’ve tried exec watch -n 10 feh bg-scale /home/meleeman/Pictures/bg-pics/ and several iterations but it will not watch the files unless I do it in a terminal session.
somehow I ended up with my primary monitor’s desktop background stuck in the center mode and it will tab or float, (doesn’t stay stationary) and the desktop background on my secondary monitor is working like it should?? Time for some more reading and trial and error…
thank you so much, helped me