Xmonad: clickable workspaces with azerty layout

Xmonad is a keyboard oriented desktop manager. But sometimes, you still want to do some mouse actions.

Dzen2 provides clickable areas that allows to bind a command to a mouse click on a specific area of a Dzen bar. If you use Dzen2 as your status bar, it is then only a question of mapping the right keystroke to the workspace name and it should work.

The standard configuration to do this is already well documented:

However I am using an azerty keyboard layout. I am then using a slightly different keyboard layout to switch workspaces. Typing “alt+1”, “alt+2” and so on to switch workspace will then not have any effect for my configuration.

An additional caveat is xdotool which does not honor default keymap unless you explicitly set it beforehand with setxkbmap.

All this taken into account, here is the resulting config snippet that works:

Note that some of my workspaces are named with plain text instead of number. I am also using the super key instead of alt as my Xmonad mod key.

If you are more Haskell fluent than I am, do not hesitate to suggest some factorization.