Search code examples
luawindow-managersawesome-wm

How to hide borders dynamically from windows when not tiled (Awesome WM)?


I'd like to remove the border from any window which is not tiled (no matter where it is maximized or just a single window assigned to a tag) and add borders as soon as it get's tiled, all while using the same layout.

I tried this solution (with changing client.add_signal to client.connect_signal): http://blog.lazut.in/2012/11/awesome-wm-remove-border-from-maximized.html

client.connect_signal("focus",
     function(c)
        if c.maximized_horizontal == true and c.maximized_vertical == true then
           c.border_width = "0"
           c.border_color = beautiful.border_focus
        else
           c.border_width = beautiful.border_width
           c.border_color = beautiful.border_focus
        end
     end)

but it only worked for some maximized windows and overwrote the borders I removed (e.g. for the synapse launcher) through properties in awful.rules.rules.

I saw the tiled(screen) function listed in the official awesome API documentation, maybe something could be done with that? I'm still new to the Awesome WM, so a little help would be appreciated.


Solution

  • This is what I have in my rc.lua to achieve the same result:

    for s = 1, screen.count() do
        screen[s]:connect_signal("arrange", function ()
            local clients = awful.client.visible(s)
            local layout  = awful.layout.getname(awful.layout.get(s))
    
            -- No borders with only one visible client or in maximized layout
            if #clients > 1 and layout ~= "max" then
                for _, c in pairs(clients) do -- Floaters always have borders
                    if not awful.rules.match(c, {class = "Synapse"}) and awful.client.floating.get(c) or layout == "floating" then                                     
                        c.border_width = beautiful.border_width
                        c.border_color = beautiful.border_focus
                    end
                end
            end
        end)
    end
    

    I added the condition if not awful.rules.match(c, {class = "Synapse"})... to handle the synapse launcher case you specified. But it may be already covered by the other conditions (the launcher should already be floating, therefore the next condition would not allow it to get a border)