简体   繁体   English

创建键绑定以将主客户端聚焦在awesome-wm中

[英]Create keybinding to focus master client in awesome-wm

I would like to create a keybinding to switch focus to the master client. 我想创建一个键绑定来将焦点切换到主客户端。 Profjim on this forum thread notes: Profjim在这个论坛帖子中注意到:

To get the master client on the current tag: 要获取当前标记上的主客户端:

 c = awful.client.getmaster() 

I have tried the following, but it causes my ~/.config/rc.lua file to be ignored, which is the behavior if there is an error in the file. 我尝试了以下操作,但它会导致我的〜/ .config / rc.lua文件被忽略,如果文件中有错误,这就是行为。 Does anyone know the correct syntax? 有谁知道正确的语法?

awful.key({ modkey,          , "e",  awful.client.getMaster()),

Note: "e" shouldn't cause any conflicts if you have the default key bindings. 注意:如果您具有默认键绑定,则“e”不应导致任何冲突。

Edit: Someone on /r/awesomewm knew the syntax to solve my problem: 编辑: / r / awesomewm上的某个人知道解决我问题的语法:

awful.key({ modkey,          }, "e",  function() client.focus = awful.client.getmaster(); client.focus:raise() end), 

Lets start with the syntax errors; 让我们从语法错误开始; from the documentation it seems that awful.key is a table, not a function. 从文档中看来, awful.key是一个表,而不是一个函数。 and it would presumably contain key s ...which are hash tables, not sequences. 并且它可能包含key s ...它们是哈希表,而不是序列。

Finally your table syntax is wrong; 最后你的表语法错了; a field may not be syntactically empty, it must have a listed value, even if that value is nil . 字段可能在语法上不为空,它必须具有列出的值,即使该值为nil

So basically you are trying to pass the wrong kind of value to something that can't be called. 所以基本上你试图将错误的值传递给无法调用的东西。


As for how to do it correctly...the documentation is confusing, and apparently I'm not the only one that thinks so. 至于如何正确地做到这一点......文档令人困惑,显然我并不是唯一一个这么认为的人。

* deep breath * * 深呼吸 *

okay, awful.new(...) creates key binders(?), and awful.key contains key bindings, so clearly we have to put the results of the first into the second. 好吧, awful.new(...) 创建键绑定器(?),而awful.key 包含键绑定,所以显然我们必须将第一个结果放到第二个。
the code on your link is but a pointer, and only covers focusing the window, not creating a keybinding. 链接上的代码只是一个指针,只覆盖窗口,而不是创建键绑定。

It seems like you want something like this: 看起来你想要这样的东西:

function do_focus()
    current = client.focus
    master  = awful.client.getmaster()
    if current then
        client.focus = master
        master:raise()
    end
end

table.insert(awful.key, awful.new (modkey, 'e', nil, do_focus) )

Bare in mind that I have no way of testing the above code. 请记住,我无法测试上面的代码。

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

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