Switching workspaces in xmonad using programmer dvorak keyboard layout (shifted numbers)

此生再无相见时 提交于 2019-12-08 17:09:22

问题


Well, I am not using Dvorak actually but Neo2, but as I am using a matrix type keyboard (Truly Ergonomic) I have also shifted the numbers.

Therefore this construction in my xmonad.hs does not work ergonomically:

-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
--
[((m .|. modMask, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]

I want to change that, to be able to access the workspaces 1 to 9 with the keys 2 to 0.

How could I achive that? I have tried to change the third line to

    | (i, k) <- zip (XMonad.workspaces conf) [xK_2 .. xK_0]

but then I could not access the 9th workspace. How do I have to change this? A short explanition would be nice, so to learn something about this construction (I learned Haskell many years ago and forgot most of it).


回答1:


Your problem is that xK_2 is bigger than xK_0, so the list [xK_2 .. xK_0] is empty:

Prelude XMonad> xK_2
50
Prelude XMonad> xK_0
48
Prelude XMonad> [xK_2 .. xK_0]
[]

You'll want to use a bit longer list than that. There's at least two reasonable ways to do this; one is to just specify all of keys yourself manually:

Prelude XMonad> [xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9, xK_0]
[50,51,52,53,54,55,56,57,48]

What I would probably use is a bit shorter:

Prelude XMonad> [xK_2 .. xK_9] ++ [xK_0]
[50,51,52,53,54,55,56,57,48]

Remember to add some parentheses if it's part of a bigger expression.



来源:https://stackoverflow.com/questions/14885806/switching-workspaces-in-xmonad-using-programmer-dvorak-keyboard-layout-shifted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!