Moving from Openbox to i3wm on Crunchbang

I have been using #! for almost 9 months with pretty much the vanilla setup. A couple of months ago, on one fateful rainy Sunday, I decided to try out a tiling window manager. Chose to go with i3wm since most cool kids appeared to be big fans.

Having used i3 for few months, I don’t think I will go back to a Floating WM ever again. I absolutely love its flexibility and the ability to control pretty much everything with key combos. It was a bit difficult to get everything working, but after the initial yak-shaving it has been butter smooth. i3’s default key combos are intuitive and I almost don’t use the mouse anymore.

I’m documenting what I had to go through cause the installation and getting everything to run smoothly was a tedious process and I couldn’t find everything I had to do in a single place.

Installation was straightforward.

sudo apt-get install i3-wm

If you want the cutting-edge version (currently 4.8), install from backports (Assuming you have the relevant entry in sources.list)

sudo apt-get -t wheezy-backports install i3-wm

If you’re using #! Waldorf you’re probably using SLIM as the display manager. Edit /etc/slim.conf from your favorite text editor so the sessions line look something like this

sessions i3,openbox-session

Logoff and in the login menu hit win+F1 to switch between WMs. When you restart next time, it will login to default WM (in this case openbox). It’s possible to make i3 default as stated here but I never bothered to change it since I hardly shutdown the laptop.

When you first login i3 will ask whether you want to use win key or alt as the mod. The key you select here will be used to invoke commands for i3 combined with other keys. You can always change this in the config file.

This will get i3 installed and running, but unfortunately the story doesn’t end here.
I mainly faced 2 problems.

  1. Power Management
  2. Volume control

Laptop continued to stay on even when I closed the lid. And there was no way to control volume.
First attempt was to make it work with a script at /etc/acpi/ which gets triggered by acpi events, but just using xfce4-power-manager turned out way more easier.

So just add exec --no-startup-id xfce4-power-manager in the i3 config (~/.i3/config) and exec --no-startup-id pnmixer for volume controls.

And following entries to control volume with fn key

bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 -- +10% && killall -SIGUSR1 i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -- -10% && killall -SIGUSR1 i3status

i3 comes with no wallpaper so to get the one we had in Openbox
just start nitrogen
exec --no-startup-id nitrogen --restore

i3 comes with a nice little program called i3bar which displays info like time, date, memory usage etc. Replace that with conky since it’s much more cooler.
Put the following in i3 config

bar {
    font xft:Inconsolata Medium 10
    status_command $HOME/.conky/conky-i3bar.sh
}

conky-i3bar.sh looks as follows

#!/bin/sh
echo '{"version":1}'
echo '['
echo '[],'
exec conky -c $HOME/.conky/conkyrc

And my conkrc

out_to_x no
own_window no
out_to_console yes
background no
max_text_width 0
update_interval 1.0
total_run_times 0
short_units on
if_up_strictness address
use_spacer left
override_utf8_locale no
cpu_avg_samples 1

TEXT
[
    {
        "full_text": " HDD:${fs_free /} "
    },
    {
        "full_text": " CPU: ${cpu cpu0}% ",
        "color":
            ${if_match ${cpu cpu0}>90}"\#FF0000"${else}
                ${if_match ${cpu cpu0}<10}"\#00CC00"${else}
                    "\#ffffff"
                ${endif}
            ${endif} 
    },
    {
        "full_text": " RAM: ${memperc}% ",
        "color":
            ${if_match ${memperc}>90}"\#FF0000"${else}
                ${if_match ${memperc}<10}"\#00CC00"${else}
                    "\#ffffff"
                ${endif}
            ${endif}
    },
    {
        "full_text": " Up: ${uptime_short} "
    },
    {
        "full_text": " C ",
        "color":
            ${if_match "${exec xset q | grep 'Caps Lock' | sed 's/.*Caps Lock:[ ]*\([^ ]*\).*/\1/'}"=="on"}"\#00CC00"${else}
                "\#CC0000"
            ${endif}
    },
    {
        "full_text": " N ",
        "color":
            ${if_match "${exec xset q | grep 'Num Lock' | sed 's/.*Num Lock:[ ]*\([^ ]*\).*/\1/'}"=="on"}"\#00CC00"${else}
                "\#CC0000"
            ${endif}
    },
    {
        "full_text": " ${time %a %d/%m/%y} ${time %H:%M:%S} ",
        "color": ${if_match ${time %u}>5}"\#00CC00"${else}"\#CC0000"${endif}
    }
],

I changed the font to Inconsolata which looks way better than the default.

One thing I missed from Openbox was cb-exit dialog box for power options. It didn’t work properly without Openbox. But no worries, there’s a fork of it called i3-exit

Place it under ~/.i3/ and bind a key combo.

bindsym $mod+Shift+x exec python $HOME/.i3/i3-exit.py

I also changed i3-exit.py a bit so it uses xscreenserver instead of i3lock.
i3lock doesn’t come with i3 and didn’t want to install it since #! already comes with xscreenserver.
Just replace
os.system(prefix + "i3-lock")
with os.system("xscreensaver-command -l")
And make a startup entry for xscreenserver
exec --no-startup-id xscreensaver -no-splash
and you’re done.

i3 comes with lots of features, be sure to check out i3 user’s guide It has all the info on default keybindings along with PICTURES!!

 
4
Kudos
 
4
Kudos

Now read this

Harry Potter, P versus NP and time travel

Sorry for the clickbait of a title. Disclaimer: Might contain HPMOR spoilers. In the last KopiJS session, I came to know about Harry Potter and the Methods of Rationality. It’s a fanfic based on HP universe. I’m not a fanfic kind of guy... Continue →