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

StackOverflow https://stackoverflow.com/questions/14885806

سؤال

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).

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top