I am using left Alt as my primary modkey, but for certain application I would like to use Alt+keys as my bindings, and for that specific application I want left winkey to be my modkey.
It seems that logHook is the right place to plug this logic in, but I have troubles understanding, how to do it.
Greatly simplified, my configuration looks like
import qualified XMonad.StackSet as W
import XMonad
import XMonad.Hooks.DynamicLog
main = do
-- some stuff
xmonad $ defaultConfig {
modMask = mod1Mask -- left winkey = mod4Mask, left alt = mod1Mask
, logHook = do
dynamicLogWithPP pp
}
where
pp = dzenPP {
-- more stuff
}
I could getName of current window in my logHook
winset <- gets windowset
let wname = fmap getName (W.peek winset) -- here I have some window identificator in Maybe
but I do not understand how to replace modMask in my main function, in defaultConfig, on the fly.
I would also be happy if on one workspace modkey will be different. Say, on workspaces 1 to 8 it is an Alt key, and on 9th it's left Winkey. This would do fine too, and I bet such solution can be easily modified to be based on currently focused window.
Best Answer
This failed. XMonad works as expected, but applications do not receive pressed keys. I mean, I use winkey as modKey on 5th workspace, and altkey on other workspaces. I used to switch workspaces with modKey+number. When I press Alt+2 on 5th workspace, XMonad does nothing (which is correct), and application does nothing (which is wrong). Chrome does not switch to 2nd tab, and so on.
Okay, so I managed to do it, using XMonad.Actions.PerWorkspaceKeys.
Related configuration:
List modifiedKeys will use modifier (in this example — Winkey on 5th workspace, and left Alt on all others), list unmodifiedKeys is used as is.
Still might look into window-specific keys later, but I'm done for now.