Tuesday, September 4, 2012

Fluxbox: I liked it! :)

On my last post I said that I was gonna try Openbox and Fluxbox WMs. I'd install Fluxbox on my Xubuntu laptop (gotta keep it with Xubuntu so I can have a system like my wife's in case she needs it) and on my other laptop I'd install Archbang, a preconfigured Arch Linux that comes with Openbox as WM.

Firstly, I tried to install Archbang but I'd always get the same error (crazy dump code on the screen a few seconds after the system is fully loaded). I tried it using a CD (actually, two, since my first guess was that I had a bad burn) and then wrote the CD image to a USB stick (see this) and tried booting from it (using plop, see my sixth post) but got the same error. The weird part is that I tried both the CD and USB stick on my other laptop and both worked without a hitch, but didn't go through with the Archbang installation though. I have no idea what is the issue, so I gave up on the idea of installing Archbang... for now.

The other part of my plan was to install Fluxbox on my Xubuntu laptop, which was easy enough to do: sudo apt-get install fluxbox, on a xfce terminal. Before trying Fluxbox, I watched this video on youtube that shows the basic configuration of Fluxbox. If you've never used it and want to try, I recommend watching this video, it's very didactic. After watching the video I figured it was time to actually try Fluxbox. Rebooted, marked "Fluxbox" on the session field of LighDM and logged in.

I should have taken a screenshot of the desktop just after I logged in. I forgot and I only have a screenshot of my current desktop. What I will do is describe my impressions of Fluxbox and what I had to do to have the desktop you see below.

Current desktop.
Before I write down how I got to this desktop, I have to say my feelings about this WM: like the title of the post says, I liked it. I actually liked it enough to keep it as my main WM on this laptop for just two reasons: it's fast and functional. The first thing you notice after logging in is that Fluxbox is very responsive, menus pop up instantly and it loads really fast, unlike the stock Xubuntu. The amount of RAM it takes is very small, making more room for other programs to run. After booting and logging in, only 95.8 MB of RAM is used. In the case of the stock Xubuntu (and with compositing disabled!), 165.1 MB of RAM is taken just after logging in on this same laptop! And that's with compositing disabled! I also liked the fact that using Fluxbox will make you go to the terminal sometimes, which to me is actually a good thing. Also, we'll see below that the most part of the configuration is done on text files. That's why it's such a fast WM: it has a simple text-based configuration scheme. It's a functional WM because it's easely configured and completely configurable. It may take sometime to make it look and feel just  the way you like it, but once you get to that point it's a fantastic WM. I plan to install some major distro (probably Slackware, since I always wanted to try it) on my other laptop and use the same configuration files I made on this Fluxbox setup. To sum up, for me, Fluxbox is fast and functional, but if you don't like the CLI or making configs on text files (*ahem* Unity *ahem*), Fluxbox may not be for you.

Now then, I'm ready to describe my experience, step by step. The first time I logged in I got a black wallpaper with a Ubuntu logo and a grey bar on the lower side of the screen, which is the toolbar. Also, there were no icons on the desktop, and to get any icons on it, a separate program is needed: idesk. Didn't install it though, I don't need stinking icons on the desktop. :)  The usual way you interact with Fluxbox is by right-clicking on the desktop. By doing that, you'll get a menu with a lot of options, from Applications menu to Configurations menus that will help you customize your Fluxbox environment. Now, in the beginning of the "config process" it's worth noting a few menus: Configuration, that lets you set transparency, toolbar options, etc, Styles that lets you set a visual style for the menus and Workspaces which lets you set how many workspaces you want.

After logging in, I opened thunar, the XFCE file manager, and found out that no icons appeared. I mean, I saw the directories, but no icons appeared. A bit of googling around pointed me to a little program called lxappearance. The program is very straight forward and it lets you choose the icon theme, mouse icons, etc.

With thunar configured, it was time to set the wallpaper. Like the guy shows on the video: fbsetbg -a /path/to/picture.jpg &. This, in my case, did not make this setting persistent, that is, after rebooting, the wallpaper that was up was the Ubuntu default one. To solve this, I had to put this command on the ~/.fluxbox/startup file (more on this file below). The weird part is that I commented this line I had added on the startup file and set a new wallpaper using the same command but a different picture. It just worked, I got a persistent wallpaper.

Having set the wallpaper I figured it was time to customize my right-click menu, the most important menu of Fluxbox! I did just like the guy on the video: edited ~/.fluxbox/menu file and added what I needed. The syntax is very straight forward and easy to pick up. The most difficult part was to find the icons I wanted to place beside the menu entries. I just added the programs I use the most, one menu just for the main Fluxbox configuration files (menu, startup, keys, init), a reboot entry and a shutdown entry. Here's how my menu file turned out:

[begin] (Fluxbox!)
[exec] (LeafPad) {/usr/bin/leafpad} </usr/share/icons/hicolor/32x32/apps/leafpad.png>
[exec] (Thunar) {/usr/bin/thunar} </usr/share/icons/hicolor/48x48/apps/Thunar.png>
[exec] (Spyder) {/usr/bin/spyder} </usr/share/app-install/icons/spyder.png>
[exec] (Audacious) {/usr/bin/audacious} </usr/share/icons/hicolor/48x48/apps/audacious.png>
[exec] (SMPlayer) {/usr/bin/smplayer} </usr/share/icons/hicolor/32x32/apps/smplayer.png>
[exec] (Xfce Application Finder) {xfce4-appfinder} </usr/share/icons/hicolor/48x48/apps/xfce4-appfinder.png>
[exec] (Task Manager) {xfce4-taskmanager} </usr/share/app-install/icons/utilities-system-monitor.png>
[exec] (Xfce Terminal) {/usr/bin/xfce4-terminal} </usr/share/app-install/icons/terminal-tango.png>
[exec] (Chromium) {/usr/bin/chromium-browser} </usr/share/icons/hicolor/32x32/apps/chromium-browser.png>
[exec] (Lock Screen) {/usr/bin/xscreensaver-command -lock} </usr/share/icons/gnome/48x48/status/changes-prevent.png>
[exec] (LibreOffice) {/usr/bin/libreoffice} </usr/share/icons/hicolor/32x32/apps/libreoffice-main.png>
[exec] (Calculator) {/usr/bin/galculator} </usr/share/app-install/icons/accessories-calculator.png>
[separator]
[submenu] (Fluxbox Config!) {}
   [exec] (Menu) {/usr/bin/leafpad ~/.fluxbox/menu} <>
   [exec] (Keys) {/usr/bin/leafpad ~/.fluxbox/keys} <>
   [exec] (Startup) {/usr/bin/leafpad ~/.fluxbox/startup} <>
   [exec] (Init) {/usr/bin/leafpad ~/.fluxbox/init} <>
[end]
[separator]
[include] (/etc/X11/fluxbox/fluxbox-menu)
[separator]
[exec] (Reboot) {sudo reboot} <>
[exec] (Shutdown) {sudo shutdown -h now} <>
[end]

This menu looks like this:
My Fluxbox menu!

To get the last two commands working without supplying the password (which would be kinda boring having to supply my password every time I wanted to shutdown or reboot) I added the following lines to my sudoers file:

%sudo   ALL=(ALL:ALL) ALL
%sudo   ALL=NOPASSWD: /sbin/shutdown,/sbin/reboot

The first line says that members of the group sudo can supply admin commands using sudo (duh!) and the second line says that members of the group sudo do not need to supply a password to execute the commands reboot and shutdown.

The next file I attacked was the ~/.fluxbox/keys. This file sets the keyboard shortcuts. It's also a very important part of the Fluxbox experience. Relying only on the right-click menu to run programs is not practical sometimes. Again, customizing the keys file is easy enough. Below are the lines I added myself to the default keys file:

# Functionalities
Mod4 Right :NextWorkspace
Mod4 Left :PrevWorkspace
Control 1 :Workspace 1
Control 2 :Workspace 2
Mod4 d :ShowDesktop
Mod4 l :Exec xscreensaver-command -lock

# Apps
Mod4 w :Exec chromium-browser
Mod4 e :Exec thunar
Mod4 t :Exec xfce4-terminal
Mod4 r :Exec xfce4-appfinder
Mod4 c :ToggleCmd {Exec pkill conky} {Exec conky -c ~/.conkyrc}

Control means the Ctrl key, Mod1 means Alt and Mod4 means the "super" (a.k.a Windows) key. The commands above are self explanatory, maybe except for the last one, which I'll explain. I set up conky to be started upon startup (see below), so that command toggles conky on/off. This ToggleCmd command is simple and brilliant, it simply commutes between two states. There are other Fluxbox commands like MacroCmd that executes several commands at once (see here for more details). Also, ToggleCmd, MacroCmd and others can be combined. There are many customizing possibilities.

Next: the ~/.fluxbox/startup file. This script is read and executed by the program /usr/bin/startfluxbox (which is the program that starts the Fluxbox session). Here are the lines I added:

xscreensaver &
nm-applet &
volumeicon &
conky -c ~/.conkyrc &

This is the stuff I run at startup. The first and the last probably don't need any explanation (just so you know, I based my .conkyrc file on this). As for the two in the middle, when you first log into Fluxbox, there are no icons on the task bar. So I needed icons for NetworkManager (for wifi) and a volume icon to appear, and that's how it's done. Easy or what?

After I put those icons on my toolbar, they were not on the corner like I wanted them to be. That brings me to the last file I edited:  ~/.fluxbox/init. This file sets the overall "look" of Fluxbox, including the toolbar. I only edited the line that sets what the toolbar must contain. It ended up like this:

session.screen0.toolbar.tools: iconbar, clock, systemtray

That line says that, from left to right, the toolbar contains an area for the iconbar, where the running windows are displayed, the clock (which you can configure how you want it by right-clicking on it) and the systemtray that, in my case, shows the NetworkManager and the volume icons.

After all that, I managed to get my desktop the way I showed in the beginning of the post. :)

There are a lot of other stuff that I didn't have time to explore, such as the ~/.fluxbox/apps file and the slit (there's even more stuff, of course). But from what I have already seen, I really liked this WM. For those willing to try it, the Fluxbox Wiki is a great source of information.

I'll see if I can get Slackware running with Fluxbox on my other laptop. In the mean time, I'll install Openbox on this "Xubuntu turned Fluxbox" laptop. Let's see how that turns out.

No comments:

Post a Comment