0

在我切换到符合人体工程学的键盘布局,即 Bépo ( http://bepo.fr/wiki/Accueil )之前,我一直是 XMonad 的长期用户。

在那之前,我一直在为我的键盘使用 XMonad.Config.Azerty 模块。但是由于布局更改,键盘快捷键被破坏了。
更准确地说是切换工作区(home+1=workspace1,home+2=workspace2,等等...)。
然后我切换回默认配置,但并没有更好。

我显然不再需要 defaultAzerty 函数了。
有人知道我应该怎么做才能重新映射家庭 +1..9 组合以便他们工作。

编辑:更新配置

这是我的配置:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Arrows #-}

import XMonad
import Graphics.X11.ExtraTypes.XF86
import qualified Data.Map as M
import qualified XMonad.StackSet as W
import XMonad.Hooks.DynamicLog
--
import XMonad.Layout.NoBorders
--
import Data.Ratio
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Spacing
import XMonad.Layout.Grid
import XMonad.Layout.IM

main :: IO ()
main = xmonad =<< xmobar myConf

-- |Main configuration, override the defaults to your liking.
myConf = defaultConfig
   { modMask = mod4Mask
   , terminal = "urxvt"
   , layoutHook = smartBorders $ myLayout
   , workspaces = myWorkspaces
   , keys = myKeys }

-- | Keyboard keys
homeMask :: KeyMask
homeMask =  133 -- from the xev data

keysToAdd x =
    [ ((mod4Mask, xK_F4 ), kill)
    , ((0, xF86XK_Calculator ), spawn "mate-calculator")
    , ((0, xF86XK_WWW ), spawn "firefox")
    , ((0, xF86XK_HomePage ), spawn "caja")
    , ((0, xK_Print ), spawn "mate-screenshot")
    , ((mod4Mask, xK_z ), spawn "emacs") ]
    ++
    [((m .|. homeMask, k), windows $ f i) 
       | (i, k) <- zip (XMonad.workspaces defaultConfig) [10 .. 19]
       , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)] ]

keysToDel x = [((mod4Mask .|. shiftMask), xK_c)] -- to delete the unused keys

myKeys x = foldr M.delete (keysToAdd' x) (keysToDel x)
  where
    -- to include new keys to existing keys
    keysToAdd' x = M.union (keys defaultConfig x) (M.fromList (keysToAdd x))

-- |Workspaces listing
myWorkspaces = ["1:main", "2:edit", "3:web", "4:browse", "5:irc", "6:pidgin"]

-- |Default layout
myLayout = pidgin $ Mirror tiled ||| tiled ||| Full
    where
        -- pidgin conf
        pidgin = onWorkspace "6:pidgin" pidginLayout
        pidginLayout = withIM (18/100) (Role "buddy_list") gridLayout
        gridLayout = spacing 8 $ Grid

        -- default tiling algorithm partitions the screen into two panes
        tiled = spacing 2 $ Tall nmaster delta ratio
        -- The default number of windows in the master pane
        nmaster = 1
        -- Default proportion of screen occupied by master pane
        ratio = 2/3
        -- Percent of screen to increment by when resizing panes
        delta = 5/100

我也看到了那篇文章,但我不知道这是否是我想要的:Switching workspaces in xmonad usingprogrammer dvorak keyboard layout (shifted numbers)

我对 haskell 语言没有任何问题,但 XMonad API 就是这么大。

EDIT2:按照这里写的http://blacketernal.wordpress.com/set-up-key-mappings-with-xmodmap/,我的主键已经是一个修饰符

这是最后几行的转储:

xmodmap:每个修饰符最多 4 个键,(括号中的键码):

shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x42) control Control_L (0x25), Control_R (0x69) mod1
Alt_L (0x40), Meta_L (0xcd) mod2 Num_Lock (0x4d) mod3
mod4 Super_L (0x85), Super_R (0x86) ), Super_L (0xce), Hyper_L (0xcf) mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)

4

1 回答 1

1

我使用的基本方法是启动 xev,输入您想要做某事的组合键,然后注意显示的键符。如果我理解正确,您想键入 Home+1 将您带到工作区 1。当我尝试这样做时,我得到以下内容,但您的结果可能不同

KeyRelease event, serial 33, synthetic NO, window 0x2600001,
    root 0x1dc, subw 0x0, time 255407786, (1090,771), root:(1093,774),
    state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x2600001,
    root 0x1dc, subw 0x0, time 255407938, (1090,771), root:(1093,774),
    state 0x0, keycode 110 (keysym 0xff50, Home), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

接下来,将适当的钩子添加到 xmonad。看看你引用的那篇文章,也许这样的东西会起作用?

homeMask              :: KeyMask
homeMask              =  110 -- from the xev data

[((m .|. homeMask, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]

编辑:在你调试这个之前,也许一个更简单的测试是为了确保我们正确地捕获了 Home 键。将以下内容添加到您的配置中:

homeMask              :: KeyMask
homeMask              =  110 -- from the xev data

并将其放入keysToAdd您的配置中:

, ((homeMask, xK_z                    ), spawn "emacs")

现在重新启动 XMonad 并查看 Home+z 是否启动 emacs。

于 2013-10-15T14:25:18.523 回答