[xmonad] How to bind w,e,s,d keys for 4 screens?
Alistair Gee
alistair.gee at gmail.com
Fri Jul 10 10:44:11 EDT 2009
I have 4 monitors in a 2x2 configuration. I would like to replace the
w-e-r key bindings with w-e-s-d key bindings to match my 2x2
configuration, but it does not work. Specifically, the w & e keys
work, but the s & d keys do not work.
My code to set these key bindings is a modification of the standard
xmonad.hs template from xmonad 0.8. (My modifications are at the end.)
I would like the following mapping:
s -> screen 1
d -> screen 2
w -> screen 3
e -> screen 4
Here is the section from my xmonad.hs file. My attempt at binding the
keys is at the end.
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
-- launch a terminal
[ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
-- launch dmenu
, ((modMask, xK_p ), spawn "exe=`dmenu_path |
dmenu` && eval \"exec $exe\"")
-- launch gmrun
, ((modMask .|. shiftMask, xK_p ), spawn "gmrun")
-- close focused window
, ((modMask .|. shiftMask, xK_c ), kill)
-- Rotate through the available layout algorithms
, ((modMask, xK_space ), sendMessage NextLayout)
-- -- Reset the layouts on the current workspace to default
-- , ((modMask .|. shiftMask, xK_space ), setLayout $
XMonad.layoutHook conf)
, ((modMask .|. shiftMask, xK_space)
, layoutScreens 4 Grid)
, ((modMask .|. controlMask .|. shiftMask, xK_space), rescreen)
-- Resize viewed windows to the correct size
, ((modMask, xK_n ), refresh)
-- Move focus to the next window
, ((modMask, xK_Tab ), windows W.focusDown)
-- Move focus to the next window
, ((modMask, xK_j ), windows W.focusDown)
-- Move focus to the previous window
, ((modMask, xK_k ), windows W.focusUp )
-- Move focus to the master window
, ((modMask, xK_m ), windows W.focusMaster )
-- Swap the focused window and the master window
, ((modMask, xK_Return), windows W.swapMaster)
-- Swap the focused window with the next window
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
-- Swap the focused window with the previous window
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp )
-- Shrink the master area
, ((modMask, xK_h ), sendMessage Shrink)
-- Expand the master area
, ((modMask, xK_l ), sendMessage Expand)
-- Push window back into tiling
, ((modMask, xK_t ), withFocused $ windows . W.sink)
-- Increment the number of windows in the master area
, ((modMask , xK_comma ), sendMessage (IncMasterN 1))
-- Deincrement the number of windows in the master area
, ((modMask , xK_period), sendMessage (IncMasterN (-1)))
-- toggle the status bar gap
-- TODO, update this binding with avoidStruts , ((modMask
, xK_b ),
-- Quit xmonad
, ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
-- Restart xmonad
, ((modMask , xK_q ), restart "xmonad" True)
]
++
--
-- 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)]]
++
--
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
--
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_s, xK_d, xK_w, xK_e] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
Note: I actually have two Xinerama screens stacked vertically, but I
use XMonad.Layout.LayoutScreens (combined with Grid) to create 4
screens in a 2x2 configuration. I don't think the LayoutScreens is
causing the problem b/c if I revert to using the w,e,r bindings, I am
able to to access 3 of the 4 screens as expected.
More information about the xmonad
mailing list