使用Xmonad和自定义键来启动功能?

时间:2016-03-07 05:29:02

标签: xmonad

我该怎么做?我尝试了以下方法,但它给我一个错误,说我的括号不匹配等。我甚至不确定函数条目是否正确

main = xmonad defaultConfig
    { terminal    = "terminator"
    , modMask     = mod4Mask
    , borderWidth = 3
    , layoutHook = myLayout
    , keys = inskeys
    }

inskeys :: XConfig l -> [((KeyMask, KeySym), X ())]
inskeys conf@(XConfig {modMask = modm}) =
[ ((mod1Mask,             xK_F2  ), saveCurrentWorkspace) ]

getLayout :: X (Layout Window)
getLayout = gets $ W.layout . W.workspace . W.current . windowset




myLayout = tiled ||| Mirror tiled ||| Full
  where
    tiled = spacing 5 $ Tall nmaster delta ratio
    nmaster = 1
    ratio = 1/2
    delta = 3/100

saveCurrentWorkspace :: X ()
saveCurrentWorkspace = do 
                        Layout x <- getLayout
                        liftIO $ writeFile "currentLayout" (show x)

1 个答案:

答案 0 :(得分:0)

要映射自定义键以启动功能,请执行以下操作。 将其添加到xmonad.hs

myAdditionalKeys = [
  ((mod1Mask .|. xK_F12), saveCurrentWorkspace),
]

并添加

`addtionialKeys myAddtionialKeys`

在“main”函数的末尾,如下例所示。

main = do
  xmonad $ defaultConfig
         { manageHook = manageSpawn <+> myManageHook <+> manageDocks,
           layoutHook = myLayout,
           logHook = dynamicLogWithPP xmobarPP {
                   ppOutput = hPutStrLn xmproc,
                   ppLayout = (\ x -> ""),
                   ppTitle = xmobarColor "#b2ed00" ""
                 } >> updatePointer (Relative 0.99 0.99),
           modMask = mod4Mask,
           borderWidth = 4,
           normalBorderColor = "#777777",
           focusedBorderColor = "#ccff00",
           workspaces = myWorkspaces,
           focusFollowsMouse = True,
           terminal = "x-terminal-emulator"
         }
         `removeKeys` myRemoveKeys
         `additionalKeys` myAdditionalKeys