Ditching xmonad for i3

I recently gave xmonad a go after seeing Nick at work using it. I liked the idea of a tiled window manager, and xmonad seemed to be popular so I tried it out. It was nice to use, but I thought that I had better give a few other options a go before I settled on xmonad, and I’m glad I did.

I watched the demo video and I was sold. Plain text config (sorry xmonad, but I don’t want to learn Haskell just yet) and the ability to split horizontally and vertically. A quick apt-get and I was up and running with the basic install. I’m not sure what I changed, but you can find a copy of my latest config file in my dotfiles repo.

There’s two sets of changes that I’ve made that I can’t live without, however. The first is to start common apps using keyboard shortcuts, the second is to change the key bindings to be more vim-like

# Start common apps
bindsym $mod+Return exec gnome-terminal # start a terminal
bindsym $mod+Shift+Return exec google-chrome # start chrome

# Change focused window                                       ($mod+[hjkl])
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
bindsym $mod+h focus left

# Move focused window                                   ($mod+Shift+[hjkl])
bindsym $mod+Shift+J move down
bindsym $mod+Shift+K move up
bindsym $mod+Shift+L move right
bindsym $mod+Shift+H move left

# Resize Containers, Vim-style                        ($mod+Control+[hjkl])
bindsym $mod+Control+j resize grow height 10 px or 10 ppt
bindsym $mod+Control+k resize shrink height 10 px or 10 ppt
bindsym $mod+Control+l resize grow width 10 px or 10 ppt
bindsym $mod+Control+h resize shrink width 10 px or 10 ppt

I name my workspaces so I can see at a glance where I need to be, rather than remembering numbers. You do this just by naming the workspace something different and binding a keyboard shortcut to it, e.g.:

bindsym $mod+9 workspace 9: im

Workspace names don’t have to start with a number, but as I use $mod+[0-9] to change between them, it helps me out. Theoretically, you could have as many workspaces as there are key combinations.

Another nice feature of i3 is that you can automatically assign windows to workspaces. Take the following example for keeping Pidgin windows on one workspace:

assign [title="^Pidgin"] 9: im

I’ve not set this up properly yet (as I can’t work out how to move it when the title changes, e.g. for things like irssi), but I can see it being very useful in the future.

As I don’t have auto-moving set up, I just do it by hand for now using the following bindings:

# Move focused container to workspace
bindsym $mod+Shift+exclam move container to workspace 1
bindsym $mod+Shift+quotedbl move container to workspace 2: www
bindsym $mod+Shift+sterling move container to workspace 3
bindsym $mod+Shift+dollar move container to workspace 4
bindsym $mod+Shift+percent move container to workspace 5
bindsym $mod+Shift+asciicircum move container to workspace 6
bindsym $mod+Shift+ampersand move container to workspace 7
bindsym $mod+Shift+asterisk move container to workspace 8
bindsym $mod+Shift+parenleft move container to workspace 9: im
bindsym $mod+Shift+parenright move container to workspace 10

That’s all I’ve managed to work out for now. I’m running the default i3status in the status bar which I need to take a look at, and I’ve got my wallpaper showing using feh, but it looks very plain. For now I like it, but I’m sure I’ll get pulled in by all the various different config options soon enough.

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

Thoughts on this post

Per 2013-05-09

Why would you assign $mod+6 to workspace 9?

michael 2013-05-10

That was a copy/paste mistake, thanks for pointing it out!

Leave a comment?

Leave a Reply