سؤال

I am using xmonad, and wanted a nice way to lock the screen. So I installed slock (apt-get install slock), and it works great.

Then I wanted an easy key sequence to trigger slock, so I defined this new function in xmonad.hs:

import qualified Data.Map as M

myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
        [ ((modMask .|. controlMask, xK_l),
           spawn "slock")
        ]

and added keys = myKeys in the main function.

This enabled me to nicely lock the screen using Ctrl+Alt+l, but then none of the other xmonad shortcuts would work!

Is there a way for me to add a single new key binding, but without altering any of the existing bindings?

هل كانت مفيدة؟

المحلول

As you've probably guessed, by setting keys = myKeys in the main function, what you've done is to override the default settings. You can add your keys using the additionalKeys operator, like so:

main =
   xmonad $ desktopConfig `additionalKeys` myKeys

Or, if you have some other customisations to desktopConfig,

main =
   xmonad $ desktopConfig
    { 
       -- other customisations
    } `additionalKeys` myKeys
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top