startupHook - 模糊类型变量

时间:2014-08-27 13:20:09

标签: xmonad

愚蠢的简单xmonad.hs问题......

import XMonad

myTerminal = "gnome-terminal"
startupHook = do { spawn "/usr/bin/feh  --bg-fill /home/abennett/wallpaper.jpg"  }

main = xmonad defaults

defaults = defaultConfig {
        terminal = myTerminal
}

引发此错误:

Error detected while loading xmonad configuration file: /home/abennett/.xmonad/xmonad.hs

xmonad.hs:4:20:
    Ambiguous type variable `m0' in the constraint:
      (MonadIO m0) arising from a use of `spawn'
    Possible cause: the monomorphism restriction applied to the following:
      Main.startupHook :: m0 () (bound at xmonad.hs:4:1)
    Probable fix: give these definition(s) an explicit type signature
                  or use -XNoMonomorphismRestriction
    In a stmt of a 'do' block:
      spawn "/usr/bin/feh  --bg-fill /home/abennett/wallpaper.jpg"
    In the expression:
      do { spawn "/usr/bin/feh  --bg-fill /home/abennett/wallpaper.jpg" }
    In an equation for `Main.startupHook':
        Main.startupHook
          = do { spawn
                   "/usr/bin/feh  --bg-fill /home/abennett/wallpaper.jpg" }

Please check the file for errors

我尝试了startupHook = startup然后startup = do { spawn "stuff" }之类的内容,但这也不起作用。

1 个答案:

答案 0 :(得分:2)

您必须在startupHook中加入defaults。您可以直接在defaults中指定,也可以创建变量并将startupHook定义为例如myStartupHookdefaults中的import XMonad main = xmonad defaults defaults = defaultConfig { terminal = myTerminal, startupHook = myStartupHook } myTerminal = "gnome-terminal" myStartupHook = do spawn "/usr/bin/feh --bg-fill /home/abennett/wallpaper.jpg" -- and more stuff like spawn myTerminal spawn "xclock" (就像您对终端所做的那样):

spawnOn

当您开始使用更多工作区时,您可能希望使用从XMonad.Actions.SpawnOn导入的{{1}}。

请查看xmonad config template,它会让您更好地了解如何构建配置文件。

相关问题