简体   繁体   English

如何在XMonad中重新配置1..9工作区键盘快捷键?

[英]How to reconfigure the 1..9 workspace keyboard shortcuts in XMonad?

I have been a long time user of XMonad until I switched to an ergonomic keyboard layout, namely the Bépo ( http://bepo.fr/wiki/Accueil ). 我一直是XMonad的长期用户,直到我切换到符合人体工程学的键盘布局,即Bépo( http://bepo.fr/wiki/Accueil )。

Until thenI was using the XMonad.Config.Azerty module for my keyboard. 在那之前,我一直在为键盘使用XMonad.Config.Azerty模块。 But since the layout change the keyboard shorcuts were broken. 但是由于布局更改,键盘快捷键已损坏。
More exactly the workpaces switching ones (home+1=workspace1, home+2=workspace2, etc...). 更确切地说,是工作区切换区(home + 1 = workspace1,home + 2 = workspace2等)。
I then switched back to the default config but it was not better. 然后,我切换回默认配置,但这并不好。

I obviously does not need the defaultAzerty function anymore. 我显然不再需要defaultAzerty函数。
Does someone know what should I be doing to remap the home +1..9 combinaison so that they work. 有人知道我应该怎么做才能重新映射家庭+ 1..9组合,以便他们工作。

EDIT : updated config 编辑:更新的配置

Here is my config : 这是我的配置:

{-# 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

Also I saw that post but I don't know if it is what I want : Switching workspaces in xmonad using programmer dvorak keyboard layout (shifted numbers) 我也看到了那篇文章,但我不知道这是我想要的: 使用程序员dvorak键盘布局(移位数字)在xmonad中切换工作区

I have no problem with the haskell language but the XMonad API is that big. 我对haskell语言没有问题,但是XMonad API太大了。

EDIT2 : following what is written here http://blacketernal.wordpress.com/set-up-key-mappings-with-xmodmap/ , my home key is already a modifier EDIT2:按照此处的内容http://blacketernal.wordpress.com/set-up-key-mappings-with-xmodmap/ ,我的主键已经是修饰符

Here is the dump of the last lines : 这是最后几行的转储:

xmodmap: up to 4 keys per modifier, (keycodes in parentheses): xmodmap:每个修饰符最多4个键,(括号中的键代码):

shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x42) control Control_L (0x25), Control_R (0x69) mod1 Shift Shift_L(0x32),Shift_R(0x3e)锁定Caps_Lock(0x42)控件Control_L(0x25),Control_R(0x69)mod1
Alt_L (0x40), Meta_L (0xcd) mod2 Num_Lock (0x4d) mod3 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) mod4 Super_L(0x85),Super_R(0x86),Super_L(0xce),Hyper_L(0xcf)mod5 ISO_Level3_Shift(0x5c),Mode_switch(0xcb)

The basic approach I use is to launch xev, type the key combination that you want to do something, and notice what keysyms show up. 我使用的基本方法是启动xev,键入要执行的键组合,并注意显示的是什么keyyms。 If I understand correctly, you want to type Home+1 to take you to workspace 1. When I tried that, I get the following, but your results are probably different . 如果我理解正确,您想输入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

Next you add the appropriate hook to your xmonad. 接下来,将适当的钩子添加到xmonad。 Looking at that post you referenced, maybe something like this would work? 查看您引用的那篇文章,也许这样的事情行得通吗?

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)]

EDIT: Before you go too far debugging this, perhaps a simpler test is in order to make sure we have the Home key trapped properly. 编辑:在您进行过多调试之前,也许是一个更简单的测试,以确保我们正确捕获了Home键。 Add the following to your config: 将以下内容添加到您的配置中:

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

And put this in the keysToAdd in your config: 并将其放入配置中的keysToAdd中:

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

Now restart XMonad and see if Home+z launches emacs. 现在重新启动XMonad,然后查看Home + z是否启动emacs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM