Fluxbox - a howto for beginners

Share your wisdom. Not for support questions!

Moderator: How-to Curator

Fluxbox - a howto for beginners

Postby mojoman » February 19th, 2011, 7:20 pm

Ok, so you’re fairly new to Linux and Debian, you’ve been trying out the full experience desktop environments but for some reason (hardware limitations, a love of simplicity and frugality, the twisted mindset of an anally minimalistic person etc etc) you want to try out a window manager without really knowing what to expect or how to go about setting it up. This how-to is for you.

If you want to post comments, bitch a bit or maybe even ask questions about this howto then you can do it in this thread.

There are a shitload of window managers out there. Many of them are good. I like fluxbox because it’s versatile, highly configurable yet also extremely easy to configure, light-weight and blindingly fast.

I assume you know your way around a terminal a least good enough to install programs and edit text files. In my example I’ll be using aptitude to install and nano to edit files. You use whatever makes you happy and gets the job done. I’ll be doing this is Wheezy. The procedure is the same in Lenny, Squeeze or Sid (but if you need this hand-holding you probably shouldn’t be running Sid anyway). The default configuration might differ a bit (e.g. the background and theme in Wheezy now differs a bit from what I remember from Squeeze and Lenny and how Sid looked about a year ago) but other than that it’s pretty much the same.

Ok, lets start off by installing the basics, that is fluxbox itself and some stuff we’ll be needing later on.*
Code: Select all
# aptitude install fluxbox feh fbpager

That’s it. It’s installed. You noticed how quick that was? Log out and log in again with whatever display manager you have. (GDM, KDM or whatever. If you’re using SLiM you need to configure it to display fluxbox as an alternative. If you’re not using a display manager you have to edit ~.xinitrc accordingly and start x-server manually. If you use the last two alternatives - good alternatives if you ask me - I assume you know enough to sort that part out yourself. If not, google and RTFM.)

Ok, you’re logged into to the default fluxbox. Take a moment and enjoy the minimalistic serenity. Free your mind from blinking obscenities, eye-soaring icons and bloated add-ons. Once you’ve taken that in, right-click on the desktop (this brings up the menu) and choose Applications-Terminal Emulator and open a terminal you like.
Code: Select all
$ fluxbox -i

This gives you a list of your default configuration files. These are the default files that the system falls back to if you don’t have them in ~/.fluxbox/. Since you’ve logged into fluxbox you should now have them but if not, copy them to your ~/.fluxbox/. The four main files you’ll be mucking about with while configuring fluxbox are init, keys, menu and startup, all located in ~/fluxbox/.

A window manager is about looks and functionality and we’re going to do both. Let’s start out with the looks so find a theme that you like. In the default menu there are a good selection. Right-click on the desktop to bring up the menu, select styles. You can change them on the fly so go through them until you’ve find one to your liking. Have a look at the relevant config file as you switch theme:
Code: Select all
$ less .fluxbox/init

Some of the contents in it changes on the spot as you change style so just repeat the command after each change. The different options are named in a rather self-explanatory fashion and the options are for most cases Boolean or numerical. Pour over it a while and you’ll get the idea. The style itself is stated in a line like this:
Code: Select all
session.styleFile:   /path/to/your/theme/name

System-wide style are stored in /usr/shared/fluxbox/styles but by default fluxbox also looks for user-specific styles in .fluxbox/styles/. I like to edit the default styles and just copy them to my local, adding *-modified or something to the name and change what I like. You can also download or create your own styles (see the end of this post for some styles pages).

Background are set in the themes as a color but you can set your own using whatever wallpaper you like. There are lots of ways to set backgrounds in fluxbox. I prefer the built-in wrapper fbsetbg (which calls an external program such as eterm, feh or nitrogen) because it’s as easy as falling of a log. So find a nice wallpaper that you like and then set it with fbsetbg, like this
Code: Select all
$ fbsetbg -f /path/to/your/wallpaper.jpg

The -f option is set to fullscreen (which is default and therefore redundant but I do it out of habit) and to see the other options do
Code: Select all
$ fbsetbg -h

You can set your wallpaper fullscreen, tiled or stretched. (If you prefer a color or gradient as your wallpaper you can use fbsetroot instead). Read up on it and experiment your way to whatever makes you tick. The last wallpaper you have set will be remembered by the file .fluxbox/lastwallpaper so it will be there next time you log in.

While you’re at it you might as well configure the stuff available through the menu, this is behavior such as focus and maximization options, transparency and opacity, and how the slit and the tabs work. The slit and the tabs deserves a few words as these are features not found in all window managers.

The slit is where docked or withdrawn programs are placed. It means that they are fixed in that place but it is not to be confused with the apps dock in the toolbar. Common programs to place in the dock is gkrellm or fbpager. To start a program in a withdrawn state you just start it with the appropriate argument. The location of the slit can be controlled via the fluxbox menu and is written into the init file.

The tabs are a functions specific to fluxbox (though some other window managers have it too) that allow you to group several windows in one, making them tabbed. Where the tabs are placed can be controlled via the fluxbox menu and is written into the init file. How you tab them is controlled via the keys file. (More on the keys file below but I use
Code: Select all
OnTitlebar Mouse2 :StartTabbing

meaning that when I press the middle mouse botton on the titlebar I can drag it to another window to group them together.)

Ok, let’s have a look at functionality now. Two things, a nice menu and good key/mousebindings, is essential for the complete window manager experience. There is a tool to do the job (fluxconf I think it's called) but in my experience that tool is not very adequate. Be a man and edit your config files by hand.

The keys file in fluxbox is a marvel of simplicity. A lobotomized baboon could manage to configure it adequately and your average geek can use it to make fluxbox a highly productive environment. This is your chance to show where between these two poles you belong. Have a look at the keys file, it’s already filled up with useful stuff.
Code: Select all
$ nano ~/.fluxbox/keys

Most of the contents is self-explanatory. Control is CTRL-key, Shift is ... wait for it ... the shift key, Mod1 is ALT, MOD4 is the Windows key. The basic structure of a key command is
Code: Select all
<mod> [<mod> <mod>] key [key key] :command <command_options>

I use key bindings to control volume, to execute programs, to manipulate windows (send to other workspaces, maximize, minimize, move, close etc), control media players and volume, etc etc. In order to map out keys you don’t know how to name, use xev. (It comes with some X-utility but I don’t remember which. If you have xorg installed you should have it.)
Code: Select all
$ xev

push the key you need to map out. You’ll get an output in the terminal containing lots of information and the piece you’re looking for is “keycode XXX”, where XXX is a three-digit number. This number is used as the value for “key” in the example above. A few examples from my keys file:
Code: Select all
None 107 :ExecCommand scrot
None 166 :ExecCommand xfce4-terminal
None 135 :ToggleCmd {RootMenu} {HideMenus}

Key 107 is Print Screen and it executes scrot, which takes a screen shot, key 166 is an extra key ←) that I use to bring up a terminal and key 135 is the Menu key, which I use to toggle the fluxbox menu (because I want to be able to do bring it up without mouse, especially when the desktop is not visible) Of course, “None” can be substituted for CTRL, MOD1 or MOD4 or whatever combination you want.

The menu file is also a tribute to simplicity and logic, though a bit more tedious to edit by hand. Still, I prefer to build it up from scratch. The standard syntax is simple, like this:
Code: Select all
[identifier]   (name)      {command}      <icon>

S0, “identifier” tells you what it is, i.e. a sub-menu, a separator, a command to be executed, etc, “name” is what is displayed on the menu, “command” is the code to be executed, e.g. wesnoth -w, and "icon contains the path to the icon displayed on the menu.

The [identifier] is mandatory, the other two are not always necessary (e.g. a separator is just a separator and takes no additional info, a sub-menu can be named but issues no command, icons are never needed). You can nest sub-menus within other sub-menus, add (rather complicated) commands, use built-in building blocks and in short make the menu look anyway you please. I prefer to built a menu that contains programs I use a just about always in the first row, a few sub-menus with stuff I use a lot below that, a fluxbox menu for the configuration stuff (with my own styles and backgrounds too) and a debian menu that allows me to access any program that is installed on the computer. I top this off with an exit submenu, that allows me to quit or shutdown. Have a look at the screenshot at the end of this post to see how my menu looks.

Christ on a crutch, this was easy, and fun too, huh? Let’s add some external stuff, just to add some functionality and to pimp things up. As you have noted, fluxbox comes with a sort of panel called the toolbar. Its looks is defined in the style file and what goes in it is controlled in the init file. You can control placement and behavior via the fluxbox menu and it too gets written to the init file.

Icons, how about icons on the desktop? Well, I don’t use them because I think they are useless and clutter the desktop. If God wanted us to use icons he wouldn’t have given us key bindings, would he? Besides, it’s for sissies but if you insist, have a look at fbdesk or idesk. When it comes to information on how to configure these beasts, I suggest you use this, this or this.

If you want a sound mixer have a look at wmmixer or mixer.app. I prefer to use key bindings and stuff such as amixer but your ymmv.

When it comes to pagers I really like fbpager. It has a neat feature that allows you to move a window on the desktop by grabbing it on pager the pager. I have a TwinView setup with a monitor and a projector, where the projector is actually in another room. When a program pops up in the part of the desktop displayed on my own little silver screen, it can be a bitch to move it but fbpager allows me to grab it on the pager and just move it to the monitor part of the desktop. Eat that KDE! In the screenshot below you can see the pager withdrawn in the slit (which is placed bottom center) so that it actually runs over the toolbar. I tried to blend it with the theme by using the colors from the wallpaper.

Ok, but you still want some stuff autostarted when you crank up fluxbox, right? Easy, you just use fluxbox own startup script, located in ~./fluxbox and logically named startup. You should have one by default and should be able to remove the comments (#) before those lines you want activated. Then add whatever you like. Remember to end any the command to start a program with “&” so that the following line is executed to, and remember to start fluxbox last using “exec fluxbox”. I also put in my fbsetbg command i startup, so that I always start with the same wallpaper, even if I have changed it during my setting but that’s just a preference I have. Other than that, I start fbpager, claws-mail, skype and pidgin.

An alternative to using autostart is to add stuff in your ~/.xinitrc. The difference is that the commands will then be run whenever you start x-server, regardless of window manager. I prefer to use the startup scripts of the different window managers, because even if I use the same programs I usually use different config files (e.g. I use conky both in fluxbox and openbox but I specify what config files they are to use in its respective script, making them look and do stuff different). However, stuff you want regardless of graphical environment may very well be placed here.

Finally, here are some resources for you to have a look at (called RTFM, which is a good thing and the path the enlightenment).
Code: Select all
$ man fluxbox
$ man fbpager


Here are some reading for you to do:
Fluxbox official home page. Go there. Buy a T-shirt.
http://www.fluxbox.org/

Fluxbox wiki (which is really good and contains lots and lots of useful info)
http://fluxbox-wiki.org/index.php?title=Fluxbox-wiki

Some theme and styles resources
http://customize.org/fluxbox
http://www.tenr.de/styles/

And a screenshot of my current fluxbox desktop (which have been around for a while actually). The Black with Debian (only partly visible) is the projector part of the desktop and the white below is dead area.
Image

* fbsetbg is a wrapper that calls another program, by default I think it's eterm but it can also call feh. You can substitute feh for eterm and probably others too but you need something for it to call.

edit 2011-02-25, some typos, added info about icons in the menu
Seriously, Stable is for senior citizens and Sid is for kids. Be a man and run Testing.
User avatar
mojoman
 
Posts: 415
Joined: February 9th, 2011, 12:33 pm
Location: In the neck of the wood

Return to HowTo

Who is online

Users browsing this forum: Ezooms [Bot] and 2 guests

x