6

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.

4

3 回答 3

7

这是我的 Awesome 4.2 版本:

screen.connect_signal("arrange", function (s)
    local max = s.selected_tag.layout.name == "max"
    local only_one = #s.tiled_clients == 1 -- use tiled_clients so that other floating windows don't affect the count
    -- but iterate over clients instead of tiled_clients as tiled_clients doesn't include maximized windows
    for _, c in pairs(s.clients) do
        if (max or only_one) and not c.floating or c.maximized then
            c.border_width = 0
        else
            c.border_width = beautiful.border_width
        end
    end
end)

我相信它可以正确处理最大化的窗口、布局中唯一可见的窗口以及“最大”布局中的窗口。它还应该忽略浮动客户端。

于 2018-08-04T16:01:26.470 回答
3

这就是我在 rc.lua 中实现相同结果的方法:

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

我添加了条件if not awful.rules.match(c, {class = "Synapse"})...来处理您指定的突触启动器案例。但它可能已经被其他条件覆盖(启动器应该已经浮动,因此下一个条件不允许它获得边界)

于 2015-06-09T23:35:49.033 回答
2

在 awesome 4.0 中,标题栏提供了比窗口边框更大的灵活性。我使用标题栏来创建顶部和左侧边框。这样,我有边框来区分平铺模式下的客户端,但我仍然可以将鼠标移动到屏幕的右侧或底部边缘并单击滚动条。这也有助于我判断哪个是重点客户。

这是我的一部分,我theme.lua在其中定义theme.bar_width

-- {{{ Borders
theme.useless_gap   = 0
theme.border_width  = 0
theme.bar_width = 2
theme.border_normal = "#3F3F3F"
theme.border_focus  = "#6F6F6F"
theme.border_marked = "#CC9393"
-- }}}

以下是我的两部分,我rc.lua在其中定义了两个标题栏:

client.connect_signal("request::titlebars", function(c)
    -- ...

    -- The top bar
    -- code was: awful.titlebar(c) : setup { ...
    -- code became:
    awful.titlebar(c, {
        position = "top",
        bg_normal = beautiful.border_normal,
        bg_focus  = beautiful.border_focus,
    }):setup{
        -- ...
    }

    -- The left bar
    awful.titlebar(c, {
        position = "left",
        size = beautiful.bar_width,
        bg_normal = beautiful.border_normal,
        bg_focus  = beautiful.border_focus,
    })

    -- ...
end)
于 2017-11-05T04:24:18.987 回答