简体   繁体   English

很棒的 wm,保持应用程序的焦点异常

[英]Awesome wm, keep focus exception for an application

In awesome wm I use gmrun, a small application launcher.在很棒的 wm 中,我使用 gmrun,一个小型应用程序启动器。

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

and this is my rules for all clients section这是我对所有客户部分的规则

awful.rules.rules = {
-- All clients will match this rule.
{ 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 },

I would like gmrun to always keep focus (an exception on the rule, normally the new opened client gets the focus) I 've read this page, but didn't find the solution, Always-on-top window and keeping focus, on AwesomeWM Thanks in advance我希望 gmrun 始终保持焦点(规则的一个例外,通常是新打开的客户端获得焦点)我已经阅读了这个页面,但没有找到解决方案, 始终在顶部窗口并保持焦点,在AwesomeWM提前致谢

Create custom focus filter function创建自定义焦点过滤器功能

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

Edit your main rule编辑您的主要规则

awful.rules.rules = {
    -- All clients will match this rule.
    { rule = { },
      properties = { ....
                     focus = custom_focus_filter,
                     .... } },

and gmrun rule和 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 },

Additioally, you may need to edit every place in your config where client.focus = used (eg sloppy focus, client buttons).此外,您可能需要编辑配置中使用client.focus =每个位置(例如,草率焦点、客户端按钮)。 For example例如

clientbuttons = awful.util.table.join(
    awful.button({ }, 1, function (c) if custom_focus_filter(c) then client.focus = c; c:raise() end end),
    ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM