FS#25964 - [xmonad-contrib] removeKeys function bug

Attached to Project: Community Packages
Opened by Jesse (crashenx) - Sunday, 11 September 2011, 15:17 GMT
Last edited by Jelle van der Waa (jelly) - Monday, 06 February 2012, 17:01 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Vesa Kaihlavirta (vegai)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

The removeKeys function in XMonad.Util.EZConfig only operates on the first element in the list.
There is an existing fix for this bug on github that can be applied:

https://github.com/bogner/xmonadcontrib/commit/81dd78145cfaa0a8484d96649f0501996eb0e70b

An example with a workaround is provided below.

Additional info:
* package version(s)

local/xmonad-contrib 0.9.2-2.1

* config and/or log files etc.

.xmonad/xmonad.hs:

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig
import XMonad.Layout.WindowNavigation
import System.IO

main = do
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig
{ manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ windowNavigation
$ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
, borderWidth = 2
, terminal = "urxvt"
, normalBorderColor = "#333333"
, focusedBorderColor = "#FFAA00"
}

-- Remove bindings to keys so they can be reassigned
--
-- NOTE: There is a bug in removeKeys that makes it act like what
-- you would expect from a function called removeKey (i.e. it only
-- operates on the first element in a list). Therefore, it is
-- currently being called for each keymapping that needs to be
-- unbound. Once the bug fix has been pulled into the current
-- xmonad-contrib package the code commented below can replace the
-- repeated calls below:
--
--`removeKeys`
--[ (i, j) | i <- [mod4Mask, mod4Mask .|. shiftMask],
-- j <- [xK_h, xK_j, xK_k, xK_l]
--]
`removeKeys` [ (mod4Mask, xK_h) ]
`removeKeys` [ (mod4Mask, xK_j) ]
`removeKeys` [ (mod4Mask, xK_k) ]
`removeKeys` [ (mod4Mask, xK_l) ]
`removeKeys` [ (mod4Mask .|. shiftMask, xK_h) ]
`removeKeys` [ (mod4Mask .|. shiftMask, xK_j) ]
`removeKeys` [ (mod4Mask .|. shiftMask, xK_k) ]
`removeKeys` [ (mod4Mask .|. shiftMask, xK_l) ]

--`additionalKeys`
-- Add bindings for moving windows within a workspace
--[ ((mod4Mask .|. shiftMask, xK_h), sendMessage $ Swap L)
--, ((mod4Mask .|. shiftMask, xK_j), sendMessage $ Swap D)
--, ((mod4Mask .|. shiftMask, xK_k), sendMessage $ Swap U)
--, ((mod4Mask .|. shiftMask, xK_l), sendMessage $ Swap R)
--, ((mod4Mask, xK_h), sendMessage $ Go L)
--, ((mod4Mask, xK_j), sendMessage $ Go D)
--, ((mod4Mask, xK_k), sendMessage $ Go U)
--, ((mod4Mask, xK_l), sendMessage $ Go R)
--]


Steps to reproduce:

Start xmonad using the provided xmonad.hs (Make sure that the xmonad.hs file has been compiled with xmonad --recompile). Open multiple windows (e.g. a terminal and 2 firefox windows). Attempt to use any of the key bindings that have been removed using removeKeys function. None should work. Change the xmonad.hs file above to use the commented out removeKeys code and comment out the existing removeKeys code:

`removeKeys`
[ (i, j) | i <- [mod4Mask, mod4Mask .|. shiftMask],
j <- [xK_h, xK_j, xK_k, xK_l]
]
--`removeKeys` [ (mod4Mask, xK_h) ]
--`removeKeys` [ (mod4Mask, xK_j) ]
--`removeKeys` [ (mod4Mask, xK_k) ]
--`removeKeys` [ (mod4Mask, xK_l) ]
--`removeKeys` [ (mod4Mask .|. shiftMask, xK_h) ]
--`removeKeys` [ (mod4Mask .|. shiftMask, xK_j) ]
--`removeKeys` [ (mod4Mask .|. shiftMask, xK_k) ]
--`removeKeys` [ (mod4Mask .|. shiftMask, xK_l) ]

Run xmonad --recompile

Hit your mod4 key + q to reload

Try to use the keybindings removed. Only mod4 + h will not work because it is the first list element. (Note that mod-shift-h and mod-shift-l are not by default bound to anything and these removeKey commands are extraneous).
This task depends upon

Closed by  Jelle van der Waa (jelly)
Monday, 06 February 2012, 17:01 GMT
Reason for closing:  Fixed
Additional comments about closing:  fixed by upstream in 0.10
Comment by Jakob Matthes (jakobm) - Monday, 12 September 2011, 15:17 GMT
Can you file this upstream (http://code.google.com/p/xmonad/issues/list) and attach the patch there?
Comment by Jesse (crashenx) - Saturday, 17 September 2011, 20:03 GMT Comment by Jelle van der Waa (jelly) - Tuesday, 31 January 2012, 14:27 GMT
No time to test atm, but is it fixed in 0.10?
Comment by Jakob Matthes (jakobm) - Sunday, 05 February 2012, 12:38 GMT
The changes to EZConfig.hs are in 0.10, for both removeMouseBindings and removeKeys.

Loading...