Fluxbox

Recently, I came across a new window manager that I like, known as Fluxbox. It's based on Blackbox, and fairly compatible with it. It's supposedly a little lighter, though subjectively, I haven't noticed much difference. It's available in the ports collection of FreeBSD, the portage collection of Gentoo, and has its home here on Sourceforge.

Much of it is like Blackbox. However, it has a few nice points of its own. I'm certainly no expert on its use, however, this page might save the reader a few minutes of searching their documentation.

It will install in the same place as would Blackbox. In RH it installs itself into /usr/local/share, in FreeBSD in /usr/X11R6/share. For purposes of example, I'll use the version current at time of writing, v0.1.6 To install it, assuming you got it from Sourceforge, you install the rpm with

rpm -Uvh fluxbox-0.1.6.rpm

(Although they recommend against using it) If it's a tar.gz then

tar -zxvf fluxbox-0.1.6.tar.gz
cd fluxbox-0.1.6
./configure; make; make install

When finished, you'll have a fluxbox directory (see above for location--in most Linux distros it'll be in /usr/share/fluxbox or /usr/local/share/fluxbox.

To start it, edit your .xinitrc or .Xclients (in RH) to read

exec fluxbox

There is an article on Fluxbox's site about installing and starting Fluxbox for the beginner that may also be useful. You'll note some differences--for instance, they suggest that .xinitrc should have the full path to the executable, but I haven't found it necessary. (I would have done it that way but didn't read the article before starting, so assumed that it would work with a simple exec fluxbox)

As I've been using it primarily in RH, for the purposes of this article, we'll assume it's in /usr/local/share)

In there you'll see several other directories, such as styles, init, keys, etc. You can leave everything there. I've sometimes found copying them to my home directory problematic--there's a patch on their page for it, but I'm lazy. :) However, you can copy over the init.

cd

(that makes sure you're in your home directory)

mkdir .fluxbox
cp -r /usr/local/share/fluxbox/init .fluxbox/

Now, your home .fluxbox directory has its own init. (In general, it's a good idea to copy init, keys and menu to the home directory--for example, in FreeBSD, I found that sometimes, making changes to the main menu, which in FreeBSD is in /usr/X11R6/share/fluxbox, would have no effect unless I copied it to the user's home directory) In later versions, it seems that if you've made the .fluxbox directory before installation, Fluxbox will put those three files in there.

Ok, so first the init directory. The init file has several perameters--it starts with a style called Clean. You can change this to a different style (the majority are the same as the Blackbox styles) if you wish. Find the line that reads

session.styleFile: /usr/local/share/fluxbox/styles/Clean

Change Clean to the style that you wish to have upon startup. Say you wish to start with Rancor. You would change the above session.styleFile to

session.styleFile: /usr/local/share/fluxbox/styles/Rancor

A quick note on the init file--recently, I was finding that despite changing the strftimeFormat parameter to %I:%M (which should give the time in 24 hour format) it was still giving me 12 hour format. The man page (In FreeBSD) didn't give me the answer--however, there's a parameter not mentioned in that man page, clockFormat. This was set to 12. It apparently overrode the strftimeFormat parameter. Changing it to 24 fixed the problem, and I got my 24 hour format.

For editing the start menu or changing backgrounds the process is almost the same as described in my article on Blackbox.

A quick example of menus.

Open your home directory's .fluxbox/menu file. You'll see that the pattern of a menu item is

[exec] (xterm) {xterm}

The exec means you can execute the command (hrrm, that was obvious), the second item is how it will appear in the menu and the third, in curly braces (or French braces if you prefer) is the actual command. So, say you wanted to add kterm, an xterminal that can input and output Japanese. You want it to appear directly under the listing for xterm. So, under the listing for xterm add

[exec] (kterm) {kterm}

The second listing is how it will appear when you right click on the desktop (which is how one sees available menu options). So, I could write Kterm or KTERM in there--it makes no difference, it only affects what I see when right-clicking to view the menu. One can add whatever programs they wish, under the pre-existing menus and submenus.

Another file in the /usr/local/share/fluxbox directory is keys. The default file looks like


Mod1 Tab :NextWindow
Mod1 Shift Tab :PrevWindow
Mod1 F1 :Workspace1
Mod1 F2 :Workspace2
Mod1 F3 :Workspace3
Mod1 F4 :Workspace4
Mod1 F5 :Workspace5
Mod1 F6 :Workspace6
Mod1 F7 :Workspace7
Mod1 F8 :Workspace8
Mod1 F9 :Workspace9
Mod1 F10 :Workspace10
Mod1 F11 :Workspace11
Mod1 F12 :Workspace12

Mod1 refers to the Alt key. So, as in MS Windows, you can go from window to window with the Alt + Tab. It accepts the same parameters as bbkeys (actually, I think they have a script to convert your bbkeysrc file, though I didn't use it.) So, say you want Alt+F4 to close whatever you're in, as it does in Windows, Alt+m to minimize a window and, familiar with MS Windows, the Windows key plus r to open up an xterm.

Change the Mod1 F4 :workspace4 to read
Mod1 F4 :Close

Now we'll add the Alt+m to minimize a window
Mod1 m :ShadeWindow

You'll note, if you're familiar with Blackbox, that the syntax and commands are generally the same as bbkeys.

The ExecCommand feature is handy.

Mod4 r :ExecCommand xterm

Mod4 refers to the Windows key, that is the key on most keyboards with the MS logo. ExecCommand, curiously enough executes a command, in this
case, xterm. You can make as many of these as you want--for instance, if you wanted Alt+k to start kmail you could add

Mod1 k :ExecCommand kmail

If the Mod4 key doesn't work, it means that when you set up X you probably picked a 101 key rather than 104 key keyboard. This is easily fixed. You'll need to be root or use sudo. Open up your favorite text editor and open /etc/X11/XF86Config. (In RH, you'd use /etc/X11/XF86Config-4). In there you will find the line

Option "XkbModel" "pc101"

Change it to read
Option "XkbModel" "pc104"

If you don't have that pc101 line in there, then you have some other problem that I haven't come across. There's other nice things you can do with the key bindings. For example, you can open up the root menu, move windows with keystrokes, etc. I have for example, in my fluxbox keys file
Mod4 j :BigNudgeDown
Mod4 k :BigNudgeUp
Mod4 h :BigNudgeLeft
Mod4 l :BigNudgeRight

If you use vi, you'll recognize why I chose those particular letters, since they duplicate vi movement commands. You can also simply use the more prosaic Up Down Left Right with whatever Mod key you choose, and then use the arrow keys, such as
Mod4 Down :BigNudgeDown

If you did that, then the Windows key and down arrow will move the window down.

For ArchLinux Users

If you have installed fluxbox, you will see a note directing you to this page for information on using the rootmenu patch. Here is that information. :)

ArchLinux, as well as Gentoo, have added a patch to Flux to enable the user to navigate the rootmenu with keystrokes. Here are my keybindings for it.

Mod4 KP_Enter :RootMenu
Mod4 KP_1 :SelectMenuItem
Mod4 KP_2 :NextMenuItem
Mod4 KP_5 :PrevMenuItem
Mod4 KP_4 :CloseMenu
Mod4 KP_6 :OpenSubMenu

The KP_ refers to the keypad. You don't have to use the keypad keys, of course, that's my choice

The actual patch itself was written by Mr. Junichiro Kita. He mentions that he plans to keep the patch updated as fluxbox is updated, and keeps the patch on his site.

As of November, 2003 ArchLinux has also included Mr. Kita's patch in their package build. They send the user here for details about its use.

FreeBSD

For those less-experienced with these things, here is how you can apply the patch in FreeBSD.

cd /usr/ports/x11-wm/fluxbox
make extract

Once the source is extracted.

cd work/fluxbox-0.1.14/src

Now, we get the patch.


fetch http://kitaj.no-ip.com/files/fluxbox/fluxbox-0.1.14-menukey.patch

(We're assuming you have the 0-1.14 version of fluxbox, otherwise change the version number accordingly).

patch < fluxbox-0.1.14-menukey.patch

Once the patch has been applied

cd ../../..
make install 

The above method also works with Linux. As far as I know, only Gentoo and Arch incorporate Mr. Kita's patch. However, downloading the fluxbox tarball and patching it as mentioned above should work in most Linux distributions.

Debian

Debian can be a bit tricky if you're not familiar with its method of building source packages. Although this is covered in their faq somewhere, here is the information.

apt-get build-dep fluxbox
apt-get source fluxbox
apt-get install fakeroot
apt-get install dpkg-dev
apt-get install automake

(You may already have fakeroot and dpkg-dev installed). Although apt-get build-dep fluxbox should also install all necessary tools, I have found that I also have to get automake.

This will bring you three files (version number correct as of January 2004) fluxbox_0.1.14-2.orig.tar.gz, fluxbox_0.1.14-2.diff.gz and fluxbox_0.1.14-2.dsc. You will also have a fluxbox-0.1.14 directory.

The next step is
dpkg-source -x fluxbox_0.1.14-2.dsc

I'm assuming you have wget or something similar, if not do a quick

apt-get install wget

Now, we patch

cd fluxbox-0.1.14/src
wget kitaj.no-ip.com/files/fluxbox/fluxbox-0.1.14-menukey.patch
patch < fluxbox-0.1.14-menukey.patch

Now to build and install the package. You are in the fluxbox-0.1.14/src directory


cd ../
dpkg-buildpackage -rfakeroot -b

This will take some time. When it's done

dpkg -i ../fluxbox_0.1.14-2_i386.deb

It's one of those nice little features that, once you get used to it, you wonder how you managed without it.

A quick note on NetBSD

NetBSD's current package collection only includes the devel version of fluxbox. This has root menu navigation built in, however, as far as I know, you can only use the arrow keys. You can call up the root menu with any key combo you wish, but navigating it is done with the arrow keys and your choice is selected with the enter key.

Although this is nice, I prefer having my own keybindings. For those who feel the same way, I have the older 0.1.14 fluxbox NetBSD files here If you decide you want the menu patch, once you've downloaded the tarball for 0.9.14, this is how I do it. We'll assume you downloaded the tarball in /usr/pkgsrc

cd /usr/pkgsrc/wm
rm -rf fluxbox
tar -yxvf /usr/pkgsrc/fluxbox.tar.bz2
cd fluxbox
make extract

Once this is done, you'll have a work directory in your fluxbox directory. Get Mr. Kita's patch here. Again, let's say you put it in /usr/pkgsrc. You're still in /usr/pkgsrc/wm/fluxbox directory.

cd work/fluxbox-0.1.14/src
mv /usr/pkgsrc/fluxbox-0.1.14-menukey.patch .
patch < fluxbox-0.1.14-menukey.patch
cd /usr/pkgsrc/wm/fluxbox
make install

Backgrounds

This is really pretty well covered in my blackbox article so I'll just give a quick overview here. Go to your fluxbox/styles directory. (As mentioned above, this might be in /usr/share, /usr/local/share, or /usr/X11R6/local/share.) Suppose you've created an image, called image.jpg. You would like to use it as your background for the style Rancor. Make a directory in your .fluxbox directory, called backgrounds, and put the image.jpg file in there. Open the styles/Rancor file. At the end of the file, you'll see a line like

rootCommand: bsetroot -gradient interlacedflatcrossdiagonalgradient -from rgb:4c/04/03 -to black

Add the line

rootCommand: bsetbg -f ~/.fluxbox/backgrounds/image.jpg

This will (and I've found no consistancy with this), sometimes automatically tile the image, sometimes stretch it, and sometimes simply center it. If your image is the same size as your screen, then you're fine. In my case, I prefer to make smaller images and tile them, so rather than the -f option, I use

rootCommand: bsetbg -t ~/.fluxbox/backgrounds/image.jpg

This will tile the image.

If nothing happens, then it's possible that you don't have a program to properly display the image. One way to check this is to open up an xterm and type
bsetbg -t .fluxbox/backgrounds/image.jpg command. You may get messages that it's searching for a program to open the images, qiv, xv, windowmaker, etc. If it finds none of them, there may be a message giving you urls to seek them. The qiv program seems to be the smallest. However, I found that it had trouble tiling the image, so I use the slightly larger (195KB v.s 113KB--according to Gentoo's emerge -s) xli. That's not well researched, merely guessed by looking at the size of the file using Gentoo's emerge -s. (However, in Deb, xli and its dependencies use less space) (If you do wind up using Windowmaker's background command, the command is wmsetbg -t and the path to the image. With most of the other programs, a simple bsetbg -t should work.)

In FreeBSD one can simply go to /usr/ports/graphics and install one of the suggested image viewing programs. In Linux, it depends upon the distro--you might have it on the CD, in Gentoo there's probably something in /usr/portage. Otherwise, you'll have to go and download one of the programs.

Once it's all done, you should find, the next time you choose the style Rancor, that your image.jpg is its background. If you have Eterm installed, you can use the Esetroot command instead. It will automatically tile images and seems to handle the widest range of files. In that case it's simply

rootCommand Esetroot ~/.fluxbox/backgrounds/image.jpg

If you bsetbg doesn't work and you don't have Eterm, then sometimes the xsetbg command will work. I've had mixed results--sometimes, on some distros, it insisted upon having a bitmap image, other times it worked without problem. Sometimes it tiles the images, sometimes not. However, as it's included with the xv program, you shouldn't have to use it--if you have xv then bsetbg should work.

Quick Note on Fluxbox in Gentoo Linux

Their fluxbox ebuild is a little unusual in that they now have something called commonbox which holds some things that fluxbox, blackbox, and perhaps some other blackbox derivatives have in common, such as the menu file and styles directory.

The commonbox file will be installed in /usr/share if you install fluxbox. There is a fluxbox directory in there.

Icons

Some folks like icons on their desktop, regardless of Window Manager. There's a little program called Idesk that will do it. (There are others, but I happen to know one of the Idesk developers so....) Anyway, it's available here.. Just download the source (at time of writing, late October 2002, there's a masked ebuild in Gentoo Linux) untar it and take a look at the README which explains it fairly well. In a nutshell, you'll create an .ideskrc. The README explains how to use it in simple terms.

The Development Version

At time of writing (December, 2003) the development version is at 0.9.6. It has some nice features. Seems a bit faster, though that is definitely subjective. Some of the syntax seems to have changed. For example (and this is covered in the development version FAQ) the old Workspace1 Workspace2 etc is now Workspace 1 Workspace 2, with a space between Workspace and the number.

The BigNudgeUp and other directions used in keybindings no longer seem to work. Insteead one uses MoveUp MoveDown and a number, indicating the number of pixels, for example MoveUp 50.

They have added RootMenu navigation, previously only available with Mr. Kita's patch. However, I prefer Mr. Kita's patch. As noted above, one can bind whatever keys they choose to various actions in navigating the menu. With the development version, you can bind a key combination to open the root menu, however, after that you must navigate with the arrow keys and close it with the escape key. With Mr. Kita's patch, I was able to do everything by using the keypad and I hope he continues to create it when the development version becomes stable. Being able to do the whole thing in one area is far easier, especially if one can touch type.

(Quick note--the rootmenu navigation didn't seem to work in 0.9.8, the development version around April 2004. I didn't research it thoroughly, as I usually use the stable version with Mr. Kita's patch. However, it was fixed by 0.9.9)

Also, (and this is covered in the development version FAQ) bsetbg is no longer included. It has been replaced by fbsetbg.

A few ArchLinux users have found that with the devel version, when one selects exit from the rootMenu, it locks up the screen and keyboard. This has only affected a few people (including me). The workaround is to go to /var/abs/unstable/x11/fluxbox-devel and edit the PKGBUILD. Add

--disable-slit

to the configuration line that has --enable-kde and such.

Recently I found an easier fix. The default init file has the line

session.screen0.slit.autoHide: False

If one changes that line to

session.screen0.slit.autoHide: True

the problem is solved. I repeat that not all ArchLinux users have had this issue.

Having used the devel version a bit, I find that one does quickly get used to navigating the RootMenu with the builtin keystrokes. It also has a few nice eye candy tricks. For example, if you prefer a window with no decorations, until now, you had to always do the ToggleDecor thing. There is now an additional file you can put in your $HOME/.fluxbox directory called apps. Although fluxbox-devel can do this automagically if you use the Remember item from the menu shown when you right click on a window's title bar, you can also create the file manually. Mine reads

[app] (aterm)
  [Position]	{194 50}
  [Deco]	{NONE}
[end]
[app] (xbuffy)
  [Deco]	{NONE}
[end]

This opens up an aterm window where I like it and the Deco part makes it completely borderless. In my .Xdefaults I have aterm set to be transparent with a shading of 50 so, it opens up a window just slightly darker than the background.

There's been a recent problem (August 2004) with FreeBSD CURRENT and FreeBSD-5.3BETA1, where fluxbox-devel will core dump. The fix, at time of writing is

ln -s aj /etc/malloc.conf

(This can be done from anywhere--that is, you don't have to be in a specific directory to do it.)

Well, that should be enough to get you started. Enjoy