AwesomeWM: using a global title bar

This post shows how you can create a global titlebar. As I changed most of my client windows to not have a titlebar (except for floating clients), I lost the information that the clients display in their title bar.

On the other side, I didn’t like the taskbar. I know what tasks I have started and currently I don’t minimize clients (I even removed the key bindings for minimizing).

And so it was a natural though to use the space the taskbar occupied for a global titlebar.

Note: the following works with AwesomeWM v4.0. I used v4.0-127-g0be3b071.

How does it look like?

This is how the titlebar looks when I have my editor active:

img

And here when I’m in an urxvt:

img

Create the global title bar

Creating the title bar is easy enough:

local wibox = require("wibox")
local mytitle = wibox.widget {
    markup = "Awesome: press Win-s for help",
    align = "left",
    widget = wibox.widget.textbox
}

As you can see, the default text is a help text that guides you towards the new hotkey widget.

Now we need to put this title onto our screens. Look for this text

s.mytasklist, -- Middle widget

and replace it with

{ -- Middle widget
    mytitle,
    layout = wibox.container.margin,
    left = 12,
},

The extra margin gives us some leeway towards the tags, or towards a run prompt.

Connect the title bar to clients

Up to now the title bar just display this help text. That’s nice, but that’s not what we want. So we need to add some signal handlers.

The first is very simple: if a client looses focus, we remove the old text that might have been in the title bar:

client.connect_signal("unfocus", function (c)
    mytitle.markup = "Awesome: press Win-s for help"
end)

Whenever a client get’s focus, the global title bar must be updated.

Sometimes c.class doesn’t exist, sometimes c.name doesn’t exist. So we need a bit logic to make a nicely looking string even in corner cases. Let’s define a function:

local function update_title_text(c)
    local s
    if c == client.focus then
        if c.class then
            if c.name then
                s = c.class .. ": " .. c.name
            else
                s = c.class
            end
        else
            s = c.name
        end
        if s then
            mytitle.text = s
        end
    end
end

And now connect this function to the “focus” signal:

client.connect_signal("focus", update_title_text)

Many clients (e.g. “urxvt” or “emacs”) update their title on-the-fly. We can get notified about this as well. I reuse the same function:

client.connect_signal("property::name", update_title_text)

History

2017-01-22
first posting
2017-02-04
added two screen shots and reworked the signal section to reflect my current rc.lua