Configuring Fluxbox

Right now our fluxbox setup is rather bland. In this section we will take steps in order to make it a much more visually appealing, and productive working environment.



Chances are you'll want to set some sort of background image for Fluxbox. In order to do so we need to install a small image viewer called feh. su to root:

cd /usr/ports/graphics/feh
make install clean
mkdir ~/background

We change to the directory of feh, and make install clean compiles and installs feh for us. Afterwards we become user again, and create a directory for our background images. Now we can use fbsetbg. If you would like to use the same background image as I (who wouldn't want to?) you can download it here. Otherwise, use any .jpg or .png file of choice. Save it to ~/background. Now:

fbsetbg -r ~/background

-r chooses a random file from the background directory. As you may have guessed you can put a number of files in the background directory and one will be chosen randomly each time you start fluxbox. If you don't want to have a directory of images, use the following:

fbsetbg -f ~/background/darkdragon.png

Replace darkdragon.png with a choice image. Also note that you may only use .jpg and .png images. Now we'll make this change permanent.

vi ~/.fluxbox/init

Edit the rootCommand line so it looks as follows:

session.screen0.rootCommand: fbsetbg -r ~/background/

Now anytime you startup fluxbox you'll have a nice background.


If you hadn't guessed, the fluxbox menu is your right click menu. The default menu isn't bad, but it doesn't make sense to have programs in it you don't have, and to leave out programs you want to use. Fotunately the syntax of the menu file is extremely simple, and I'll explain it briefly, and give you an example menu file.

vi ~/.fluxbox/menu

Scroll down to the line "[begin] (Fluxbox-0.9.11)". This line begins the menu. You must not delete it, nor the last "[end]" statement. You can change Fluxbox-0.9.11 to whatever you want, it is the title that will be shown when you right click. Next you should see a line similar to "[exec] (xterm) {xterm}". This is a basic line in your menu, which executes something. The [exec] declares it as an execution line. (xterm) states that the menu should display "xterm". Finally {xterm} tells fluxbox what to do when you click on that menu entry. You can see how it is very easy to add your own entries to the menu. The other basic component of the menu is the submenu. It is declared as "[submenu] (title of menu)". All entries below it are a part of the submenu until an [end] is reached, where the entries then return to the main menu.

Here is a sample menu tailored to the applications in our guide. Feel free to copy and paste lines from it to use in yours. To do so, highlight text with your mouse, and click the middle button to paste. If you're pasting into vi, make sure you are in insert mode before middle clicking.

[begin] (Fluxbox)
[exec] (xterm) {xterm}
[submenu] (Tools)
      [exec] (Galculator) {galculator}
      [exec] (Gnome Commander) {gnome-commander}
      [exec] (File Roller) {file-roller}
      [exec] (K3B) {k3b}
      [exec] (Gramps) {gramps}
[submenu] (Internet)
      [exec] (Firefox) {firefox}
      [exec] (Thunderbird) {thunderbird}
      [exec] (Gaim) {gaim}
      [exec] (gFTP) {gftp}
      [exec] (Xchat) {xchat}
[submenu] (Editors)
      [exec] (Leafpad) {leafpad}
      [exec] (OpenOffice 2) {}
      [exec] (Abiword) {abiword}
      [exec] (Gnumeric) {gnumeric}
[submenu] (Multimedia)
      [exec] (Beep Media Player) {beep-media-player}
      [exec] (Grip) {grip}
      [exec] (Audacity) {audacity}
[submenu] (Graphics)
      [exec] (Gimp) {gimp}
      [exec] (Xpdf) {xpdf}
[submenu] (fluxbox menu)
      [config] (Configure)
[submenu] (Styles) {Choose a Style...}
      [workspaces] (Workspace List)
[submenu] (Tools)
      [exec] (Window name) {xprop WM_CLASS|cut -d \" -f 2|xmessage -file - -center}
      [commanddialog] (Fluxbox Command)
      [reconfig] (Reload config)
      [restart] (Restart Fluxbox)
      [exec] (About) {fluxbox -v 2>/dev/null | head -n1 | xmessage -file - -center}
      [exit] (Exit Fluxbox)
      [exec] (Reboot) {shutdown -r now}
      [exec] (Shutdown) {shutdown -p now}

Note the last two entries in my menu. Restart and shutdown. First make sure however, that your user is in the group operator. su to root. Then:

pw groupshow operator

You will see the members of the group operator now. If your username isn't listed, type:

pw groupmod operator -m username

Where username is the name of your user. Now they are able to issue the shutdown command. But first, you must logoff and logon for it to take effect.


Another great feature about fluxbox is that you can set hotkeys, to do just about anything you could want (making hotkeys which call scripts would give the ability to do anything with hotkeys you could from the command line).

vi ~/.fluxbox/keys

For reference Mod1 is Alt, at least on a standard keyboard. Let's look at making some hotkeys in order to increase our productivity.

Mod1 F1 :SendToWorkspace 1
Mod1 F2 :SendToWorkspace 2
Mod1 F3 :SendToWorkspace 3
Mod1 F4 :SendToWorkspace 4

Mod1 1 :Workspace 1
Mod1 2 :Workspace 2
Mod1 3 :Workspace 3
Mod1 4 :Workspace 4

Alt+FX sends the active window to the X'th workspace, and Alt+X switches to that workspace.

Mod1 Tab :NextGroup
Mod1 Shift Tab :PrevGroup
Mod1 g :NextTab
Mod1 Shift g :PrevTab

Alt+Tab switches between groups (windows), while Alt+g switches between tabs within the same group. Using shift reverses the direction of either operation.

Mod1 c :Close
Mod1 m :Minimize
Mod1 t :ToggleDecor

Manipulating windows is also very handy with hotkeys. Alt+c will close the active window, Alt+m will minimize it, and Alt+t will toggle window decorations (show/hide the title bar).

Mod1 X :RootMenu

Alt+x will bring up the root menu, so you can launch applications from the keyboard.

Control Mod1 x :ExecCommand xterm
Control Mod1 r :Reconfigure

Ctrl+Alt+x will launch an xterm; this is a very useful key combination. Finally, Ctrl+Alt+r will reload your fluxbox configuration, so you can refresh your configuration easily from the keyboard.

The last set of hotkeys is not useful unless you use mpd as your media player of choice. If you do, I highly recommend that you use these hotkeys. Ctrl+Up will display the current song, Ctrl+Down will toggle play and pause, and finally Ctrl+Left and Ctrl+Right will move to the previous or next track respectively. By using a simple two key combination you can control your media player with only one hand, which is very convenient in my opinion.

Control Up :ExecCommand mpc | xmessage -center -timeout 2 -file -
Control Down :ExecCommand mpc toggle
Control Left :ExecCommand mpc prev
Control Right :ExecCommand mpc next

Upon Completion of this section, your workspace should look something like this:

Return to our Previous Section