如何在未平铺时从 windows 动态隐藏边框(Awesome WM)?
How to hide borders dynamically from windows when not tiled (Awesome WM)?
我想删除任何未平铺的 window 的边框(无论它在哪里最大化或只是分配给标签的单个 window)并尽快添加边框因为它是平铺的,同时使用相同的布局。
我尝试了这个解决方案(将 client.add_signal 更改为 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)
但它仅适用于某些最大化的 windows 并覆盖了我通过 awful.rules.rules.
中的属性删除的边框(例如,对于突触启动器)
我在官方很棒的 API 文档中看到 tiled(screen)
函数,也许可以用它来做些什么?我对 Awesome WM 还是个新手,所以希望能提供一点帮助。
这就是我在 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"})...
来处理您指定的突触启动器案例。但它可能已经被其他条件覆盖(启动器应该已经浮动,因此下一个条件不允许它获得边框)
在 awesome 4.0 中,标题栏比 window 边框提供更多的灵活性。
我使用标题栏来创建顶部和左侧边框。这样,在平铺模式下我就有了区分客户端的边框,但我仍然可以将鼠标移动到屏幕的右侧或底部边缘并单击滚动条。这也有助于我判断哪个是重点客户。
这是我的 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)
这是我的 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)
我相信它能正确处理布局中唯一可见的最大化 windows、windows 和 'max' 布局中的 windows。它还会按应有的方式忽略浮动客户端。
我想删除任何未平铺的 window 的边框(无论它在哪里最大化或只是分配给标签的单个 window)并尽快添加边框因为它是平铺的,同时使用相同的布局。
我尝试了这个解决方案(将 client.add_signal 更改为 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)
但它仅适用于某些最大化的 windows 并覆盖了我通过 awful.rules.rules.
中的属性删除的边框(例如,对于突触启动器)我在官方很棒的 API 文档中看到 tiled(screen)
函数,也许可以用它来做些什么?我对 Awesome WM 还是个新手,所以希望能提供一点帮助。
这就是我在 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"})...
来处理您指定的突触启动器案例。但它可能已经被其他条件覆盖(启动器应该已经浮动,因此下一个条件不允许它获得边框)
在 awesome 4.0 中,标题栏比 window 边框提供更多的灵活性。 我使用标题栏来创建顶部和左侧边框。这样,在平铺模式下我就有了区分客户端的边框,但我仍然可以将鼠标移动到屏幕的右侧或底部边缘并单击滚动条。这也有助于我判断哪个是重点客户。
这是我的 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)
这是我的 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)
我相信它能正确处理布局中唯一可见的最大化 windows、windows 和 'max' 布局中的 windows。它还会按应有的方式忽略浮动客户端。