0

I recently decided to switch from i3wm to 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.

So I searched for xK_ names for these keys and put them in to config file like this:

[((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

Which refers to this line: , ((0 .|. modMask, xK_plus), windows $ W.greedyView "1"), specifically to | 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.

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

Perhaps you meant â\200\230xK_macronâ\200\231 (imported from XMonad)

As the suggested solution is totally different key, I simply proceeded to remove all xK_~caron and it surprisingly compiled. Now I am able to switch workspaces, but switching to 2nd workspace with ý key which is 7th in the row is kinda strange.

Now i don't understand why aren't caron keys accepted as xK_ecaron is totally valid key:

~ $ cat /usr/include/X11/keysymdef.h |grep ecaron
#define XK_ecaron                        0x01ec  /* U+011B LATIN SMALL LETTER E WITH CARON */
Community
  • 1
  • 1
Lyarenei
  • 23
  • 1
  • 6
  • Are you sure you have exactly `.|.` in your file (i.e. `"\46\124\46"`), and not perhaps some strange non-ASCII lookalike? Also, make sure all your files are UTF-8 encoded. ([Always](http://utf8everywhere.org/)!) – leftaroundabout Dec 15 '17 at 15:57
  • Yes, there is exactly byte sequence \46\124\46 in the file on that line. Also everywhere else where it should be. And it's already UTF-8 encoded. – Lyarenei Dec 15 '17 at 17:52
  • 1
    Then I really wonder how this strange `â\200\230,â\200\231` can creep in. Are those perhaps terminal escape codes which have somehow been mangled to plaintext? What terminal are you using? — Generally, it would of course also be useful to post a full configuration file, i.e. a [MCVE]. – leftaroundabout Dec 15 '17 at 18:23
  • I concur with @leftaroundabout. Keep deleting unrelated lines until you get down to as small a file as possible. Then post the file along with the output of running `xxd` on the file (or similar). – Daniel Wagner Dec 16 '17 at 06:02
  • I went straight to absolute minimal one, still no luck. I updated question with gist link to that minimal config. @leftaroundabout I am using gnome-terminal on one machine and xfce4-terminal on another. I tried editing config file with vim and VS Code. – Lyarenei Dec 16 '17 at 18:21
  • @DanielWagner I added xxd output is in the gist comments – Lyarenei Dec 16 '17 at 18:21
  • Oh, lol, â\200\230 and â\200\231 is your terminal not printing forward and backward single quotes correctly. The complaint is about the *comma*, not the pipe. This has to be included as part of a keybindings section, it can't just go anywhere... – Daniel Wagner Dec 16 '17 at 18:26
  • I was simply recompiling using xmonad restart keybind. I will use `~ $ xmonad --recompile` from now. – Lyarenei Dec 16 '17 at 19:40
  • ...and better figure out what's wrong with your terminal, this would drive me crazy. What does a simple bash command like `echo “foobar”` yield? Perhaps this is a font issue? – leftaroundabout Dec 16 '17 at 20:15
  • Terminal works correctly, as I said above I was recompiling by restart keybind, so I only saw some weird error message window (probably some generic X stuff, cant tell, I have never seen this). When I try compile it with `~$ xmonad --recompile` terminal command, the error is printed correctly in terminal window. – Lyarenei Dec 16 '17 at 21:29

1 Answers1

2

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

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Thanks, the `Graphics.X11.ExtraTypes.XorgDefault` helped, now the "more compact" style workspace keybind works perfectly. However, I can't compile your example above. When I add `import qualified Data.Map as M` to minimal config I get 3 errors: `Couldn't match expected type ‘M.Map (ButtonMask, KeySym) (X ())’ with actual type ‘XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())’` and `Couldn't match type ‘XConfig l0 -> KeyMask’ with ‘Foreign.C.Types.CUInt’ ` which is repeated. – Lyarenei Dec 16 '17 at 19:35
  • 1
    @Lyarenei Oops, yes, I forgot to bind `modMask`, so it's getting the record selector instead of the value from `conf`. You can change `\conf -> keys conf` to `\conf@(XConfig { modMask = modMask }) -> keys def conf` to fix that. Probably. (Sorry, I don't have xmonad installed on this machine to test for sure.) – Daniel Wagner Dec 16 '17 at 20:07
  • (Future readers can ignore my previous comment: I have modified the answer to include the correction posted in it.) – Daniel Wagner Dec 20 '17 at 01:26