≡ Menu

How To Change Wallpaper in Fluxbox Window Manager

Question: How do I change the desktop background wallpaper in fluxbox window manager?

Answer: We discussed fluxbox earlier in an introduction to the fluxbox window manager and how to shutdown the system from fluxbox window manager.

In this article we’ll see how to change the wallpaper in fluxbox by using a bash script or by editing the menu file.

We use a BASH script to aid us and it will be stored in ~/bin so it is readily accessible. Make sure that your $PATH is set correctly. Do this by adding the following line to your ~/.bashrc.


Install feh for fluxbox wallpaper

First step is to install feh. In Ubuntu and Debian you use the following:

sudo apt-get install feh

Whereas on FreeBSD you use the following:

sudo pkg_add -r feh

Write a bash script to set the fluxbox wallpaper

The next step is to write a script which I’ve already taken the liberty of writing.

#!/usr/bin/env bash
USAGE="Setting background:\n-t tiled\n-c center\n-s scaled\nsecond arg should be a pic"
if [ "$1" = "-t" ]
   then feh $BG_TILE $2 

elif [ "$1" = "-c" ]
   then feh $BG_CEN $2 

elif [ "$1" = "-s" ]
   then feh $BG_SCA $2 

   echo -e $USAGE

if [ ! -e "$2" ]       # Check if file exists.
      echo "Are you sure you typed the filename correctly?"

What this script does is execute certain commands based on certain conditions. The first part says if $1 (the first argument) is equal to “-t” then execute feh $BG_TILE $2, where $2 is the second argument, i.e. the path of the fluxbox wallpaper.

Set wallpaper by editing fluxbox menu

Another and even simpler way to set the fluxbox wallpaper is by editing the menu file. You can add something like the following somewhere in your menu file and you’ll get a list of all your fluxbox wallpapers (bear in mind that it won’t read subdirectories).

[wallpapers] (/path/to/wallpapers/) {command}

The “{command}” will be executed upon clicking. By default it uses fbsetbg which is simply a wrapper. It will in turn use feh to set the background.

In closing, Fluxbox is an excellent window manager who’s functionality can be extended given some creative scripting, time, and patience. In addition, it being lightweight makes it ideal for low resource systems.

Fig: Fluxbox Change Wallpaper

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Vincent February 5, 2010, 1:58 am

    What benefit does the script give you. It does thing feh does by itself…

  • Hutchy July 22, 2014, 5:38 am

    Another Way That I add wallpapers without having to install feh is to use the “fbsetbg” command like this example where I might select 2 or 3 favourite wallpapers I have in /usr/share/wallpapers or /backgrounds Folder & add to menu like this

    [exec] (SetFluxBox-WallPaper1) {/usr/local/bin/fbsetbg /usr/share/wallpapers/YourWallPaper.jpg}
    [exec] (SetFluxBox-WallPaper2) {/usr/local/bin/fbsetbg /usr/share/wallpapers/YourWallPaper.jpg}
    [exec] (SetFluxBox-WallPaper3) {/usr/local/bin/fbsetbg /usr/share/wallpapers/YourWallPaper.jpg}

    Very simple & you just click on the background you want,thanks for your examples too.