简体   繁体   English

如何在xmonad中重新绑定工作区切换为重音键?

[英]How to rebind workspace switching to accented keys in xmonad?

I recently decided to switch from i3wm to xmonad. 我最近决定从i3wm切换到xmonad。 I found this configuration and decided to try it out. 我找到了此配置,并决定尝试一下。 The config works without any problem straight out of the box. 该配置可以直接使用,没有任何问题。

The problem is, I cannot switch desktop workspaces, because I don't use english keyboard layout. 问题是,我无法切换桌面工作区,因为我不使用英文键盘布局。 I have accented characters instead of numbers under F-key row. 我在F键行下加了重音符号而不是数字。

So I searched for xK_ names for these keys and put them in to config file like this: 因此,我搜索了这些密钥的xK_名称,并将其放入配置文件中,如下所示:

[((m .|. modMask, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_plus, xK_ecaron, xK_scaron, xK_ccaron, xK_rcaron, xK_zcaron, xK_yacute, xK_aacute, xK_iacute]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

However, this didn't work. 但是,这没有用。 So I tried to bind at least one key (according to this answer ) to see if that will at least work (with that code above commented out): 因此,我尝试绑定至少一个键(根据此答案 ),以查看它是否至少有效(上面的代码已注释掉):

    , ((0 .|. modMask, xK_plus), windows $ W.greedyView "1")
    , ((shiftMask .|. modMask, xK_plus), windows $ W.shift "1")

But it didn't. 但事实并非如此。 In both cases, the error message was: 在这两种情况下,错误消息均为:

xmonad.hs:292:9: parse error on input â\\200\\230,â\\200\\231 xmonad.hs:292:9:输入â\\ 200 \\ 230,â\\ 200 \\ 231解析错误

Which refers to this line: , ((0 .|. modMask, xK_plus), windows $ W.greedyView "1") , specifically to | 引用此行: , ((0 .|. modMask, xK_plus), windows $ W.greedyView "1") ,特别是| if I am not mistaken. 如果我没有记错的话。

When I try 当我尝试

[((m .|. modMask, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

It goes without any problems, however, when I try 但是,当我尝试时,它没有任何问题

    , ((0 .|. modMask, xK_1), windows $ W.greedyView "1")
    , ((shiftMask .|. modMask, xK_1), windows $ W.shift "1")

The same error is thrown. 抛出相同的错误。

I am using Czech QWERTY layout and xmonad 0.12. 我正在使用捷克QWERTY布局和xmonad 0.12。

Could you please tell me what am I doing wrong? 你能告诉我我在做什么错吗? Thanks. 谢谢。

Edit: 编辑:

Here is minimal config file. 是最小的配置文件。

I also made some progress when I was trying my luck with another machine. 在另一台机器上尝试运气时,我也取得了一些进步。 With

[((m .|. modMask, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_plus, xK_ecaron, xK_scaron, xK_ccaron, xK_rcaron, xK_zcaron, xK_yacute, xK_aacute, xK_iacute]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

I got different error message which said (for all caron keys): 我得到了不同的错误消息,上面说(对于所有纸箱钥匙):

Not in scope: â\\200\\230xK_ecaronâ\\200\\231 不在范围内:â\\ 200 \\230xK_ecaronâ\\ 200 \\ 231

Perhaps you meant â\\200\\230xK_macronâ\\200\\231 (imported from XMonad) 也许您的意思是â\\ 200 \\230xK_macronâ\\ 200 \\ 231(从XMonad导入)

As the suggested solution is totally different key, I simply proceeded to remove all xK_~caron and it surprisingly compiled. 由于建议的解决方案是完全不同的键,因此我简单地删除了所有xK_〜caron并进行了令人惊讶的编译。 Now I am able to switch workspaces, but switching to 2nd workspace with ý key which is 7th in the row is kinda strange. 现在我可以切换工作区,但切换到与第二工作区ý关键是7日在该行是有点儿奇怪。

Now i don't understand why aren't caron keys accepted as xK_ecaron is totally valid key: 现在我不明白为什么不接受caron密钥,因为xK_ecaron是完全有效的密钥:

~ $ cat /usr/include/X11/keysymdef.h |grep ecaron
#define XK_ecaron                        0x01ec  /* U+011B LATIN SMALL LETTER E WITH CARON */

In your minimal config, 在您的最小配置中,

import XMonad
import qualified XMonad.StackSet as W

--bind xK_plus to workspace 1
    , ((0 .|. modMask, xK_plus), windows $ W.greedyView "1")
    , ((shiftMask .|. modMask, xK_plus), windows $ W.shift "1")

main = xmonad def
    { terminal    = "gnome-terminal"
    }

...you have bare keybindings in the middle of your file. ...您的文件中间没有任何键绑定。 Those have to appear as part of a keybindings list; 这些必须出现在绑定列表中。 the commas are list element separators. 逗号是列表元素的分隔符。 So: 所以:

main = xmonad def
    { terminal    = "gnome-terminal"
    , keys        = \conf@(XConfig { modMask = modMask }) -> keys def conf `mappend` M.fromList
        [ ((0 .|. modMask, xK_plus), windows $ W.greedyView "1")
        , ((shiftMask .|. modMask, xK_plus), windows $ W.shift "1")
        ]
    }

(Or similar.) (或类似)。

For your other question, xK_ecaron is available from Graphics.X11.ExtraTypes.XorgDefault . 对于您的其他问题,可以从Graphics.X11.ExtraTypes.XorgDefault获得xK_ecaron You can see a list of all available keysyms (and which module to import to get them) here , or you can search for a specific one on Hoogle . 您可以在此处查看所有可用的keyyms的列表(以及要导入的模块以获取它们),也可以在Hoogle上搜索特定的。

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

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