Fluxbox In-Depth: Mad Customization And Other Tips

Fluxbox Startup

I use Slackware for my OS and I always start X from the command line so your mileage may vary a bit here. Please bear with me as this gets a little confusing. My description will follow the chronological sequence.

When the startx command is issued the startx script executes xinit, a binary. Among other things, xinit will try to run your system’s xinitrc script(s). These can be in various locations (e.g. ~/.xinitrc or /etc/X11/xinit/xinitrc), but I believe the most common location is /etc/X11/xinit/xinitrc. That script then runs a default system startfluxbox script, which then typically runs the default user’s startup script, which in turn starts the Fluxbox binary. I have altered this sequence so that for me it goes like this:

  1. The xinit binary starts X using files like /etc/X11/xorg.conf and ~/.Xdefaults,
  2. The xinit binary then runs the xinitrc.fluxbox script,
  3. xinitrc.fluxbox merges my /etc/X11/xinit/.Xmodmap into the system’s generic settings,
  4. xinitrc.fluxbox then runs the /usr/bin/startfluxbox script,
  5. Which in turn executes the /usr/bin/fluxbox binary using the ~/.fluxbox/init file settings.

I am not a fan of the somewhat recursive nature of Fluxbox’s “startup” scripts. Fluxbox has designed them to cover the contingencies of a first-time user, a user with no startup script, and users with their own startup scripts. I understand the reasons for this, but since I’m on a single-user system, I just don’t need all this. And quite frankly, it confuses me. So I’ve eliminated a user-specific startup script, and I’ve whittled down the scripts in my sequence to using as little code as possible. Then as a matter of trying for standardization, I separate my X settings from my Fluxbox settings.

You do not have to have an .Xdefaults, and mine is used strictly for color settings; the rest of my X settings I take care of in xinitrc.fluxbox. My .Xmodmap is strictly X level keyboard mappings (like changing the Capslock key to Tab). I keep my Fluxbox settings in startfluxbox (namely, I set the background image here). Some people put all their Fluxbox settings with their X settings in xinitrc.fluxbox (I used to). Some people prefer to use more of Fluxbox’s built-in methodology for much of this stuff. Others put all their X settings in .Xdefaults. None are wrong; it’s a matter of preference. I try to keep it simple to help me keep it all straight.

Let’s look at some of these files. Of interest in my .Xmodmap I map the right Alt, Ctrl, and Windows (Super) keys to their equivalent left side keys. This is important for getting the same behavior out of each. Later I’ll talk about the Fluxbox Keys file, which can get some unexpected results if you don’t do something like this.

Now check out my xinitrc.fluxbox script where I do most everything X related. The early stuff should be pretty self-explanatory. I do a bunch of xset commands (which can be done in an .Xdefaults or various other locations). After that I do something different from most people. Rather than use a ~/.fluxbox/startup script to start apps, I run the /usr/bin/startfluxbox in the background and grab its process ID number, execute all the apps I want, and then hang there waiting until Fluxbox finishes. This is an old method that has the advantage of allowing me to execute commands after Fluxbox starts but not from within it. In other words, these apps are started from X, not Fluxbox. X won’t allow you to start applications without a running window manager, so you can’t just execute them prior to starting Fluxbox. There are various advantages and reasons for doing this, but for me its mostly about to which files I log. It also lessens the number of files I deal with.

Next we have my system startfluxbox script called from xinitrc.fluxbox. I set my background here because I want to get the image up as quickly as possible so I don’t see any default color flash for a moment. Most people just use the method Trent mentioned with the rootCommand option in the Fluxbox Init file, and it works fine. I’m just trying to squeak a couple microseconds out of it. I’ve played extensively with this, and there are several other things you can do (like using X to set the background as commented out in my xinitrc.fluxbox – very dangerous), but ultimately I decided that this is the best method for me. It’s a little faster, and again it lessens the number of files I use for configuration.

Notice that I’ve cropped quite a bit out of this script and out of the whole normal Fluxbox startup sequence as this is the only startup script to be called. At this point the Fluxbox binary launches, which brings us to the Fluxbox config files….

Next page: Fluxbox Configuration Files

About these ads

15 thoughts on “Fluxbox In-Depth: Mad Customization And Other Tips

  1. Great writeup, Pat. I’m actually going to have to play around with the Fluxbox Apps file… there’s a lot of cool functionality in that particular file that I’m just still not using, and I could get used to some of those things really quick.

    You’ve already spoiled me with the stuff I’ve lifted from your Keys file (particularly the window sizing and movement key bindings… those are really handy, and I’ve only been using them for a few weeks).

  2. Pingback: Links 04/08/2009: GNOME Dropping Icon Clutter, KDE 4.3 Finally Liked by SJVN | Boycott Novell
  3. “So when I restart my computer or even just a program, I absolutely detest having to resize and relocate windows to the way I had them before the restart”

    Have you ever tried devilspie/gdevilspie(gui)? it let’s me do that and a lot more in xfce. I’m sure you’ll like it…

    check them out:

    code.google.com/p/gdevilspie/downloads/list

    burtonini.com/blog/computers/devilspie

  4. Good post. You’ve inspired me to tweak my own FluxBox configuration a bit more. I’m going to have to play with the startup and apps files, and of course the keys file. :-)

  5. Thanks. Glad I could help. My keys file really isn’t that complicated, but you can google and find all sorts of amazing example files. Have fun!

  6. Pingback: Fluxbox and dockapps « The Linux Critic
  7. nice guide to Fluxbox, really.. I definitely share your enthusiasm about Flux’s speed, lightweight-ness, and ease of configuration/customization!

  8. Pingback: Mint Enlightenment « The Linux Critic
  9. Hi! Just want to say thank you. I’m trying out fluxbox and thanks to what you wrote and generously shared, I was able to make out what to do with it! Now I’m loving it! Keep up the good work. Take care and God bless.

  10. Quick suggestion: If you like Firefox, try Swiftfox, a speed-optimized Firefox for Linux only! While it hasn’t been updated to version 4 yet, it runs much faster than FF and goes well with Fluxbox, plus it has access to all of the extensions and add-ons as FF! Also, if you’re wanting to use a minimalistic file manager (which most Fluxboxians are), try PCManFM. It’s quick, it’s easy, and it gets the job done well.

  11. Hello Patrick,

    Tnaks for this great tutorial !

    I never found the answer to my question on the launch of programs on several desktops at fluxbox startup :
    Is it possible to launch, for example, appli#1 on desktop#2, appli#2 on #desktop#4, appli#3 on desktop #3 and so on ?

    (desktop#n = virtual desktop in fluxbox)

    If it was possible, could you tell us how to do in the startup file, to obtain this result ?

    Thanks in advance !

  12. You all are welcome. Glad to see this is still helpful even if some of the links are broken. =D But I knew that would happen eventually.

  13. @Guillaume
    I know it’s been months and you’ve probably found your answer already, but I’ll respond anyway. What you’re asking is really two different questions.

    First, to launch apps on startup, see here:
    http://fluxbox-wiki.org/index.php?title=Editing_the_startup_file

    Second, to get them to open on the different desktops (fluxbox calls them “workspaces”) you can edit the Apps file to include “[Workspace] {4}” under that app (change the number). You don’t have to edit it by hand though. If you run the app you want on the workspace you want, right-click the app’s titlebar, go down to Remember, and check the box next to Workspace. This will add the line to the Apps file for you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s