Struts in the awesome window manager
Tagged:

Awesome is a tiling window manager for X11, which automatically tiles windows nicely on your screen as soon as you open or close them. It's highly configurable: the configuration is written in the Lua language. So in fact, you're programming your own window manager to your liking.

This post explains how to use struts, since this is one of the blind spots in the documentation and anywhere else on the net.

Normally, when you open a window it will become full-screen (unless it's floating and not maximized). When you open another window, both windows will take up about half the space of your screen. This works fine in most cases, however, in the case with instant messaging clients it turns out that it doesn't work that great.

I'm used to have one virtual desktop dedicated to my instant messenger: at the right of the screen resides my contact list and chats in the remainder of the screen. This becomes a bit problematic in a tiling window manager: when no chats are open, the contact list becomes full-screen. This is not practical nor esthetically pleasing. A work-around would be to make the contact list floating, which means that it basically escapes from the tiling regime enforced by awesome. However, a new chat window will cover the full screen, including your contact list.

In this case, I would like to reserve some space at the right side of my screen to put my contact list into. The remainder of the screen is being managed by means of tiling. This reserved area is called a strut, and can be requested in a window rule.

For my instant messenger, Kopete in this case, I used the following rule in my awesome configuration:

{ rule = { class = "Kopete", role = "MainWindow#1" },
  properties = {
    floating = true,
    tag = tags[ 1 ][ 2 ]
  },
  callback = function( c )
    local w_area = screen[ c.screen ].workarea
    local strutwidth = 200
    c:struts( { right = strutwidth } )
    c:geometry( { x = w_area.width - strutwidth, width = strutwidth, y = w_area.y, height = w_area.height } )
  end
}

In this snippet, I match the rule against the contact list which has a role "MainWindow#1". It's important to make this a floating window, otherwise it will be tiled inside the large tiling area of your screen. The callback is excuted when the rule is matched. I request a strut of 200 pixels (strutwidth) at the right side of my screen. Then the geometry of the contact list should be adjusted to fit nicely into this strut. When you reserve a strut at the left side of your screen, x should be 0.

Now the chat windows or other windows are nicely tiled next to your contact list, exactly how I wanted it to be.

In case you're interested, I host my awesome configuration on Github. It's still fairly basic, but as time progresses I hope to build in a bunch of nifty tricks which should enhance my desktop experience.

Excellent thinking covering

Excellent thinking covering this. Thanks.