Debian

Xmonad.hs 添加暫存器,不在範圍內錯誤

  • November 10, 2013

嘿,我在將暫存器添加到我的 xmonad 配置時遇到了一些麻煩。

當我試圖編譯 xmonad.hs 文件時,我得到了這個:

載入 xmonad 配置時檢測到錯誤

xmonad.hs:172:34 不在“m”範圍內

請檢查文件是否有錯誤。

我對haskell的了解非常有限,我知道這可能是一個基本錯誤,但恐怕我無法解決它。

這是 xmonad.hs 配置:

--
-- Imports needed for config
--
import System.IO
import System.Exit
import XMonad
import XMonad.Actions.FindEmptyWorkspace
import XMonad.Actions.TagWindows
import XMonad.Actions.OnScreen (greedyViewOnScreen, viewOnScreen)
import XMonad.Actions.Warp
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ICCCMFocus
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat)
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Combo
import XMonad.Layout.Grid
import XMonad.Layout.LayoutModifier
import XMonad.Layout.Named
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Reflect
import XMonad.Layout.TwoPane
import XMonad.Layout.WindowNavigation
import XMonad.Layout.IndependentScreens
import XMonad.Util.WindowProperties
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Util.Run
import XMonad.Util.Dmenu
import XMonad.Util.Scratchpad
import XMonad.Prompt
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
import qualified XMonad.StackSet as S
import XMonad.Config.Gnome
import Control.Monad
import Data.Ratio
import Data.Maybe (fromMaybe)

----------------------
-- Define variables --
----------------------
myTerminal = "gnome-terminal"
myBrowser = "x-www-browser"
runMenu = spawn "dmenu_run"


-----------------------
-- Define Workspaces --
-----------------------
myWorkspaces = ["1:term","2:web","3:code","4:subl","5:media","6:vm"] ++ map show [7..9]

--
-- Define windows
-- Use 'xprop | grep WM_CLASS' to find the WM_NAME you want to move.
--

myManageHook = composeAll
   [ className =? "x-www-browser"  --> doShift "2:web"
   , className =? "Google-chrome"  --> doShift "2:web"
   , className =? "Sublime_text"   --> doShift "4:subl"
   , className =? "Eclipse"        --> doShift "3:code"
   , className =? "Java"       --> doShift "3:code"
   , className =? "spotify.exe"    --> doShift "5:media"
   , className =? "Wine"           --> doShift "5:media"
   , className =? "VirtualBox"     --> doShift "6:vm"
   , resource  =? "desktop_window" --> doIgnore
   , resource  =? "gpicview"       --> doFloat
   , className =? "MPlayer"        --> doFloat
   , className =? "stalonetray"    --> doIgnore
   , isFullscreen --> (doF W.focusDown <+> doFullFloat)] <+> manageScratchPad

manageScratchPad :: ManageHook
manageScratchPad = scratchpadManageHook (W.RationalRect l t w h)

 where

   h = 0.1     -- terminal height, 10%
   w = 1       -- terminal width, 100%
   t = 1 - h   -- distance from top edge, 90%
   l = 1 - w   -- distance from left edge, 0%


------------------------
-- Layout definitions --
------------------------

-- The layouts which xmonad switches between
myLayout = avoidStruts (
   Tall 1 (3/100) (1/2) |||
   Mirror (Tall 1 (3/100) (1/2)) |||
   tabbed shrinkText tabConfig |||
   Full |||
   spiral (6/7)) |||
   noBorders (fullscreenFull Full)


---------------------------------
-- Color and design properties --
---------------------------------


-- Define the colors and borders of windows in xmonad

myNormalBorderColor  = "#7c7c7c"
myFocusedBorderColor = "#ffb6b0"

-- Colors for text and backgrounds of each tab when in "Tabbed" layout.

tabConfig = defaultTheme {
   activeBorderColor = "#7C7C7C",
   activeTextColor = "green",
   activeColor = "#000000",
   inactiveBorderColor = "#7C7C7C",
   inactiveTextColor = "#EEEEEE",
   inactiveColor = "#000000"
}

-- Color of current window title in xmobar.
xmobarTitleColor = "#FFB6B0"

-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "green"

-- Width of the window border in pixels.
myBorderWidth = 1



------------------
-- Key bindings --
------------------

-- Setting windows button as primary action (mod)
myModMask = mod4Mask
-- Alt as secondary action.
altMask   = mod1Mask

-- Key binds
myKeys conf = M.fromList $
   [ ((myModMask              , xK_Return    ), spawn myTerminal)
   , ((myModMask              , xK_x         ), spawn myBrowser)
   , ((myModMask              , xK_r         ), runMenu)
   , ((myModMask              , xK_c         ), kill)
   -- Empty Workspace Movement
   , ((altMask                , xK_space     ), viewEmptyWorkspace)
   , ((altMask .|. shiftMask  , xK_space     ), tagToEmptyWorkspace)
   -- Layout Commands
   , ((myModMask              , xK_space     ), sendMessage NextLayout)
   , ((altMask .|. shiftMask  , xK_Return    ), sendMessage FirstLayout)
   , ((myModMask              , xK_n         ), refresh)
   , ((myModMask              , xK_m         ), windows S.swapMaster)
   -- controlling window movement, position and location

   , ((myModMask              , m            ), scratchpadSpawnActionTerminal myTerminal) // ERROR ON THIS LINE
   , ((altMask                , xK_Tab       ), windows S.focusDown)
   , ((altMask .|. shiftMask  , xK_Tab       ), windows S.focusUp)
   , ((myModMask              , xK_Tab       ), windows S.focusDown)
   , ((myModMask .|. shiftMask, xK_Tab       ), windows S.focusUp)
   , ((myModMask              , xK_Down      ), windows S.swapDown)
   , ((myModMask              , xK_Up        ), windows S.swapUp)
   , ((myModMask              , xK_Left      ), sendMessage Shrink)
   , ((myModMask              , xK_Right     ), sendMessage Expand)
   , ((myModMask              , xK_t         ), withFocused $ windows . S.sink)
   , ((myModMask              , xK_w         ), sendMessage (IncMasterN 1))
   , ((myModMask              , xK_v         ), sendMessage (IncMasterN (-1)))
   -- Shutdown commands
   , ((myModMask              , xK_q         ), restart "xmonad" True)
   , ((myModMask              , xK_h         ), spawn "gksudo pm-hibernate")
   , ((myModMask .|. shiftMask, xK_q         ), io (exitWith ExitSuccess))
   , ((myModMask .|. shiftMask, xK_w         ), spawn "gnome-screensaver-command -l")
   -- Print Screen
   , ((myModMask              , xK_Print     ), spawn "gnome-screenshot")
   , ((altMask                , xK_Print     ), spawn "gnome-screenshot -a")
   -- MPC and Volume commands
   , ((myModMask               , xK_Page_Up  ), spawn "mpc next")
   , ((myModMask               , xK_Page_Down), spawn "mpc prev")
   , ((myModMask               , xK_Pause    ), spawn "mpc toggle")
   , ((myModMask               , xK_F12      ), spawn "amixer -q set Master 5%+")
   , ((myModMask               , xK_F11      ), spawn "amixer -q set Master 5%-")
   , ((myModMask               , xK_F10      ), spawn "amixer -D pulse set Master 1+ toggle")
   , ((0                       , 0x1008ff12  ), spawn "amixer -D pulse set Master 1+ toggle")
   , ((0                       , 0x1008ff11  ), spawn "amixer -q set Master 5%-")
   , ((0                       , 0x1008ff13  ), spawn "amixer -q set Master 5%+")

   ] ++

 -- mod-[1..9], Switch to workspace N
 -- mod-shift-[1..9], Move client to workspace N
 [((m .|. myModMask, k), windows $ f i)
     | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
     , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] 

--------------------
-- Mouse bindings --
--------------------

-- Focus rules
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True


-- Movements of windows, user mod + t to reset tile.
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
 [
   -- mod-button1, Set the window to floating mode and move by dragging
   ((modMask, button1),
    (\w -> focus w >> mouseMoveWindow w))

   -- mod-button2, Raise the window to the top of the stack
   , ((modMask, button2),
      (\w -> focus w >> windows W.swapMaster))

   -- mod-button3, Set the window to floating mode and resize by dragging
   , ((modMask, button3),
      (\w -> focus w >> mouseResizeWindow w))
 ]

------------------
-- Startup hook --
------------------
myStartupHook = return ()


----------------
-- Run xmonad --
----------------
main = do
 xmproc <- spawnPipe "xmobar ~/.xmonad/xmobar.hs"
 xmonad $ defaults {
     logHook = dynamicLogWithPP $ xmobarPP {
           ppOutput = hPutStrLn xmproc
         , ppTitle = xmobarColor xmobarTitleColor "" . shorten 100
         , ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
         , ppSep = " | "
     }
     , manageHook = manageDocks <+> myManageHook
     , startupHook = setWMName "LG3D"
 }


------------------
-- Merge it all --
------------------
defaults = defaultConfig {
   -- simple stuff
   terminal           = myTerminal,
   focusFollowsMouse  = myFocusFollowsMouse,
   borderWidth        = myBorderWidth,
   modMask            = myModMask,
   workspaces         = myWorkspaces,
   normalBorderColor  = myNormalBorderColor,
   focusedBorderColor = myFocusedBorderColor,

   -- key bindings
   keys               = myKeys,
   mouseBindings      = myMouseBindings,

   -- hooks, layouts
   layoutHook         = smartBorders $ myLayout,
   manageHook         = myManageHook,
   startupHook        = myStartupHook
 }

關於錯誤是什麼?該行在文件中被標記。

菜鳥錯誤m應該是xK_m

引用自:https://unix.stackexchange.com/questions/99405