在 awesome
4.0 中,有没有办法只在 float 窗口上显示标题栏?
查看文档,似乎没有开箱即用的选项。
指定;我正在寻找一种在平铺和 float 之间动态切换窗口时有效的解决方案。
最佳答案
有点晚了,但我也想这样做,而且我大部分时间都在工作。它没有涵盖您希望客户端显示或隐藏其标题栏的所有情况,但对于我的用例来说已经足够接近了。
很简单,首先你需要为每个客户端禁用标题栏,所以在匹配所有客户端的默认规则的属性中添加titlebars_enabled = false
。
然后,当客户端开始 float 时,您需要打开他的标题栏,并在它停止 float 时将其关闭。
我写了这个小辅助函数是为了让代码更清晰。这很简单,如果 s
是 true
则显示栏,否则隐藏它。但是有一个问题,在我们的例子中,窗口从来没有标题栏,所以它还没有创建。如果当前的那个是空的,我们会发出信号让我们 build 一个。
-- Toggle titlebar on or off depending on s. Creates titlebar if it doesn't exist
local function setTitlebar(client, s)
if s then
if client.titlebar == nil then
client:emit_signal("request::titlebars", "rules", {})
end
awful.titlebar.show(client)
else
awful.titlebar.hide(client)
end
end
现在我们可以 Hook 属性更改:
--Toggle titlebar on floating status change
client.connect_signal("property::floating", function(c)
setTitlebar(c, c.floating)
end)
但这仅适用于在创建后更改状态的客户端。我们需要为天生 float 或 float 标签中的新客户提供一个 Hook :
-- Hook called when a client spawns
client.connect_signal("manage", function(c)
setTitlebar(c, c.floating or c.first_tag.layout == awful.layout.suit.floating)
end)
最后,如果当前布局是 float 的,则客户端没有设置 float 属性,因此我们需要为布局更改添加一个钩子(Hook),以便在客户端内部添加标题栏。
-- Show titlebars on tags with the floating layout
tag.connect_signal("property::layout", function(t)
-- New to Lua ?
-- pairs iterates on the table and return a key value pair
-- I don't need the key here, so I put _ to ignore it
for _, c in pairs(t:clients()) do
if t.layout == awful.layout.suit.floating then
setTitlebar(c, true)
else
setTitlebar(c, false)
end
end
end)
我不想在这上面花太多时间,所以它不包括客户在 float 布局中被标记的情况,或者客户被多次标记并且其中一个标记 float 的情况。
关于lua - 仅在 float 窗口上显示标题栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42376294/