Awesome wm,为应用程序保持焦点的例外

在 awesome wm 中,我使用 gmrun,一个小的应用程序启动器。

{ rule = { class = "Gmrun" },
  properties = { floating = true, ontop = true, focus = true }, callback = function(c) c:geometry({x=30, y=45}) end},

这是我所有客户端部分的规则

awful.rules.rules = {
-- 所有客户端都将匹配此规则。
{ rule = { },
  properties = { border_width = beautiful.border_width,
                 border_color = beautiful.border_normal,
                 focus = awful.client.focus.filter,
                 raise = true,
                 keys = clientkeys,
                 size_hints_honor = false,
                 buttons = clientbuttons }, callback = awful.client.setslave },

我希望 gmrun 总是保持焦点(规则的例外,通常新打开的客户端会获得焦点) 我阅读了这个页面,但没有找到解决办法, Always-on-top window and keeping focus, on AwesomeWM 预先感谢您

点赞
用户5803034
用户5803034

创建自定义聚焦过滤函数

local free_focus = true
local function custom_focus_filter(c) return free_focus and awful.client.focus.filter(c) end

编辑你的主要规则

awful.rules.rules = {
    -- 所有客户端都将符合此规则。
    { rule = { },
      properties = { ....
                     focus = custom_focus_filter,
                     .... } },

和 Gmrun 规则

{ rule = { class = "Gmrun" },
  properties = { floating = true, ontop = true, focus = true },
  callback = function(c)
      c:geometry({x=30, y=45})
      free_focus = false
      c:connect_signal("unmanage", function() free_focus = true end)
  end },

此外,你可能需要编辑配置文件中的每个client.focus =使用的地方(例如,松散的聚焦、客户端按钮)。例如,

clientbuttons = awful.util.table.join(
    awful.button({ }, 1, function (c) if custom_focus_filter(c) then client.focus = c; c:raise() end end),
    ....
2016-09-26 21:29:14