Wednesday, February 6, 2008

Choosing and Customizing a Window Manager

One of the fantastic things about the X Window System is the empowerment of its users. As users, we are able to choose from a slew of window managers. Gnome and KDE have percolated to the top as the most popular window managers. Personally, I believe that this is likely due to the fact that they are very similar to Microsoft Windows (95 through Vista) and therefore resemble what most people are used to. If you prefer Gnome or KDE that is more than fine with me, but there are alternatives! The most important thing is that your window manager increases your productivity and/or enjoyment. Gnome and KDE are quite similar, however there are some great window managers that often get overlooked, I suggest you try several and decide which one(s) you like!

Here are some window managers to try:

* Xfce is actually a desktop environment that uses Xfvm as a window manager

After installing one of these window managers simply add its executable to a file named .xinitrc in your home directory. If it does not exist, simply create it. For example if I downloaded and installed fluxbox and I wanted it to run instead of Gnome or KDE I would create an .xinitrc file with a single line that read "fluxbox".

With the new trend toward 3d desktops, more and more window managers are supporting 3d operations. If you have a good video card and system resources to spare (waste? ;)), you might want to look into Xgl, Beryl, Compiz, and others.

Personally, my favorite window manager is Fluxbox. It is extremely fast, small, and minimalistic in nature, but it has some wonderful features. Some example features I really love are:

  • Instead of having a "Start" menu, right clicking anywhere on the desktop produces the menu.
  • Alt+LeftClick moves a window, Alt+RightClick resizes a window
  • Scroll mouse anywhere on the desktop swaps workspaces
  • 100% customizable menu
  • Double clicking on menu bar "collapses" the window like a window shade, only leaving the title bar. Clicking on the title bar a second time expands the window.
  • Tabbing, which allows multiple windows to share the same window (hard to explain in one line, but it's really neat!)


Remember how I was talking about empowerment? Here is one example. Fluxbox is my favorite window manager, yes, but X allows me to spice things up a bit. Before explaining this further, let's review some X concepts (information taken from the Fluxbox FAQ):

You have to understand that a windowmanager is just one more application for X, like netscape or gimp or xterm. Many people new to X come to believe that X runs the window manager and the window manager runs programs. But thats not true. If configured right, you can run all your applications under X, kill the window manager, and start another window manager up. The *real* program that X runs, that runs other programs, is your .xinitrc or .xsession script. When X is started, your .xinitrc or .xsession script is run, and when the script is done, X comes down. Let me repeat that, its important: WHEN .xinitrc IS FINISHED, *THAT* IS WHEN X ENDS. It isn't when your windowmanager exits.

In the age of "Gnome or KDE?" the .xinitrc file has been somewhat forgotten. Here is another pearl of knowledge from the Slackware documentation:

xinit(1) is the program that actually starts X; it is called by startx(1), so you may not have noticed it (and probably don't really need to). Its configuration file, however, determines which programs (including and especially the window manager) are run when X starts up. xinit first checks your home directory for a .xinitrc file. If the file is found, it gets run; otherwise, /var/X11R6/lib/xinit/xinitrc (the systemwide default) is used

With this information we can do some truly wonderful things. For example, I use Fluxbox, but I like having the Gnome "taskbar" (Gnome calls it a panel) so I can use the nifty applets like weather reports, tomboy notes, battery power, volume control, online updates, time and date, and a nice calendar. These Gnome features are simply X applications and X allows me to run these "pieces" of Gnome while using Fluxbox as my window manager. All I had to do was run locate the programs running with Gnome that I wanted to run in Fluxbox. This was accomplished easily by running 'ps ax' while in Gnome. When I had the program names I wanted to run, I simply added them to my ~/.xinitrc file like so:

bean@cobweb:~> cat .xinitrc
fluxbox & wmpid=$! # start fluxbox and store the process id in a variable wmpid
gnome-panel & # run the gnome panel
sleep 10 # give the gnome panel some time to load completely, so applets will dock properly
gnome-power-manager & # run the gnome power manager (great for laptops)
#nm-applet & # run the Network Manager applet (if you're using Network Manager)
opensuse-updater-gnome-applet & # run the online update applet
gnome-volume-manager --sm-disable & # run the volume manager
xset b off # turn off that vile beep
wait $wmpid # wait for fluxbox to return

Notice that I am backgrounding these processes (i.e., I am appending '&'). If this is not done, the .xinitrc script will not continue until the process ends.

Here is a screenshot of my Fluxbox wm with a Gnome panel.

No comments: