Difference between revisions of "Xmonad (简体中文)"

From ArchWiki
Jump to: navigation, search
(Starting xmonad)
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
[[Category:简体中文]]
 
[[Category:简体中文]]
[[Category:X Server (简体中文)]]
 
 
[[Category:Tiling WMs (简体中文)]]
 
[[Category:Tiling WMs (简体中文)]]
{{i18n|Xmonad}}
+
[[en:Xmonad]]
 +
[[fr:Xmonad]]
 +
[[tr:Xmonad_Pencere_Yöneticisi]]
 
{{translateme (简体中文)}}
 
{{translateme (简体中文)}}
  
Line 43: Line 44:
 
   setxkbmap -layout de
 
   setxkbmap -layout de
 
   # 启动xmonad
 
   # 启动xmonad
   exec ck-launch-session xmonad
+
   exec xmonad
  
===Configuring xmonad===
+
===配置xmonad===
  
xmonad users can modify, override or extend the default settings with the {{ic|~/.xmonad/xmonad.hs}} configuration file. Recompiling is done on the fly, with the Mod+q shortcut.
+
xmonad的默认配置文件是{{ic|~/.xmonad/xmonad.hs}},如果{{ic|~/.xmonad/}}路径下没有{{ic|xmonad.hs}}文件,可以从{{ic|/usr/share/xmonad-VERSION/man/xmonad.hs}}拷贝一份。可以通过编辑{{ic|~/.xmonad/xmonad.hs}}文件对xmonad进行自定义和扩展。
  
If you find you do not have a directory at {{ic|~/.xmonad}}, run {{Ic|xmonad --recompile}} to create it.
+
要使配置生效需要重新编译xmonad,重编译不需要退出xmonad。可以在终端中输入{{Ic|xmonad --recompile}},也可以使用快捷键{{ic|Mod+q}}进行重编译。Mod默认是Alt键。
  
The "default config" for xmonad is quite usable and it is achieved by simply running without an {{ic|xmonad.hs}} entirely.  Therefore, even after you run {{Ic|xmonad --recompile}} you will most likely not have an {{ic|~/.xmonad/xmonad.hs}} file.  If you would like to start tweaking things, simply create the file and edit it as described below.
+
因为xmonad配置文件是用Haskell语言写的,非程序员可能会在配置时遇到困难。更多帮助和一些配置文件示例可以从以下链接找到:
 
+
Because the xmonad configuration file is written in Haskell, non-programmers may have a difficult time adjusting settings.  For detailed HOWTO's and example configs, we refer you to the following resources:
+
  
 
* [http://haskell.org/haskellwiki/Xmonad xmonad wiki]
 
* [http://haskell.org/haskellwiki/Xmonad xmonad wiki]
 
* [http://haskell.org/haskellwiki/Xmonad/Config_archive xmonad config archive]
 
* [http://haskell.org/haskellwiki/Xmonad/Config_archive xmonad config archive]
 
* [http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions xmonad FAQ]
 
* [http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions xmonad FAQ]
* Arch Linux [http://bbs.archlinux.org/viewtopic.php?id=40636 forum thread]
+
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=40636 forum thread]
  
The best approach is to only place your changes and customizations in {{ic|~/.xmonad/xmonad.hs}} and write it such that any unset parameters are picked up from the built-in defaultConfig.
+
自定义配置最好都写在{{ic|~/.xmonad/xmonad.hs}}文件里,并且应该把未设置的参数交给内置的defaultConfig处理。
  
This is achieved by writing an {{ic|xmonad.hs}} like this:
+
如下面这个示例文件:
  
 
   import XMonad
 
   import XMonad
Line 73: Line 72:
 
       }
 
       }
  
This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the function defaultConfig).
+
它仅仅将默认终端设置为"urxvt“,Mod键设置为“Windows键”,边框宽度设置为3,其它参数的设置都采用默认值(从defaultConfig函数继承)
  
As things get more complicated, it can be handy to call configuration options by function name inside the main function, and define these separately in their own sections of your {{ic|~/.xmonad/xmonad.hs}}. This makes large customizations like your layout and manage hooks easier to visualize and maintain.
+
当配置项变多以后,在主函数里将函数名配给参数的做法会更方便。不同的函数置于{{ic|~/.xmonad/xmonad.hs}}文件的不同部分。这样的话,大范围的自定义配置会更易于维护。
  
The simple {{ic|xmonad.hs}} from above could have been written like this:
+
按照这个思路,上面那个简单的{{ic|xmonad.hs}}示例文件,可以写成下面这样:
  
 
   import XMonad
 
   import XMonad
Line 88: Line 87:
 
       }
 
       }
 
   
 
   
   -- yes, these are functions; just very simple ones
+
   -- 是的,这些也都是函数,只不过是简单函数
   -- that accept no input and return static values
+
   -- 它们不接受输入变量,返回静态值
 
   myTerminal    = "urxvt"
 
   myTerminal    = "urxvt"
   myModMask    = mod4Mask -- Win key or Super_L
+
   myModMask    = mod4Mask -- Windows键或Super_L键
 
   myBorderWidth = 3
 
   myBorderWidth = 3
  
Also, order at top level (main, myTerminal, myModMask etc.), or within the {} does not matter in Haskell, as long as imports come first.
+
函数(如main, myTerminal, myModMask)的定义顺序或在{}中的顺序是不重要的,只要import语句是在文件起始位置就可以。
  
The following is taken from the 0.9 config file template found [http://haskell.org/haskellwiki/Xmonad/Config_archive/Template_xmonad.hs_(0.9) here]. It is an example of the most common functions one might want to define in their main do block.
+
下面的例子摘自xmonad 0.9的配置文件模板,完整模板在[http://haskell.org/haskellwiki/Xmonad/Config_archive/Template_xmonad.hs_(0.9) 这里]。这个例子包含了经常会在main函数里自定义的项。
 
   
 
   
 
   {
 
   {
Line 103: Line 102:
 
     borderWidth        = myBorderWidth,
 
     borderWidth        = myBorderWidth,
 
     modMask            = myModMask,
 
     modMask            = myModMask,
     -- numlockMask deprecated in 0.9.1
+
     -- 0.9.1之后已经弃用了numlockMask
 
     -- numlockMask        = myNumlockMask,
 
     -- numlockMask        = myNumlockMask,
 
     workspaces        = myWorkspaces,
 
     workspaces        = myWorkspaces,
Line 109: Line 108:
 
     focusedBorderColor = myFocusedBorderColor,
 
     focusedBorderColor = myFocusedBorderColor,
 
   
 
   
     -- key bindings
+
     -- 快捷键
 
     keys              = myKeys,
 
     keys              = myKeys,
 
     mouseBindings      = myMouseBindings,
 
     mouseBindings      = myMouseBindings,
 
   
 
   
     -- hooks, layouts
+
     -- 事件钩子、窗口布局
 
     layoutHook        = myLayout,
 
     layoutHook        = myLayout,
 
     manageHook        = myManageHook,
 
     manageHook        = myManageHook,
Line 121: Line 120:
 
   }
 
   }
  
Also consider copying/starting with {{ic|/usr/share/xmonad-VERSION/man/xmonad.hs}}, which is the latest official example xmonad.hs that comes with the '''xmonad''' Haskell module.
+
推荐参考{{ic|/usr/share/xmonad-VERSION/man/xmonad.hs}}文件,它是官方最新的xmonad.hs示例文件,在安装xmonad时自带。
  
===Exiting xmonad===
+
===退出xmonad===
To end the current xmonad session, press {{Keypress|Mod+Shift+Q}}. By default, {{Keypress|Mod}} is the {{Keypress|Alt}} key.
+
按下组合键 {{ic|Mod+Shift+Q}} 来结束当前的xmonad会话。默认设置下, {{ic|Mod}} {{ic|Alt}} key.
  
 
==Tips and tricks==
 
==Tips and tricks==
Line 220: Line 219:
 
Firstly, you can use the following xmonad extension, [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ServerMode.html XMonad.Hooks.ServerMode].
 
Firstly, you can use the following xmonad extension, [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ServerMode.html XMonad.Hooks.ServerMode].
  
Secondly, you can simulate keypress events using {{Pkg|xdotool}} or similar programs. See this [http://ubuntuforums.org/archive/index.php/t-658040.html Ubuntu forums thread]. The following command would simulate the keypress {{Keypress|Super+n}}:
+
Secondly, you can simulate keypress events using {{Pkg|xdotool}} or similar programs. See this [http://ubuntuforums.org/archive/index.php/t-658040.html Ubuntu forums thread]. The following command would simulate the keypress {{ic|Super+n}}:
 
  xdotool key Super+n
 
  xdotool key Super+n
  
Line 255: Line 254:
 
</nowiki>}}
 
</nowiki>}}
  
Just remember to add a comma before or after and change the path to your actual script path. Now just {{Keypress|Mod+q}} (restart xmonad to refresh the config), and then hit {{Keypress|Mod+Shift+o}} and you should have Openbox running with the same windows open as in xmonad. To return to xmonad you should just exit Openbox. Here is a link to adamvo's {{ic|~/.xmonad/xmonad.hs}} which uses this setup [http://www.haskell.org/haskellwiki/Xmonad/Config_archive/adamvo%27s_xmonad.hs Adamvo's xmonad.hs]
+
Just remember to add a comma before or after and change the path to your actual script path. Now just {{ic|Mod+q}} (restart xmonad to refresh the config), and then hit {{ic|Mod+Shift+o}} and you should have Openbox running with the same windows open as in xmonad. To return to xmonad you should just exit Openbox. Here is a link to adamvo's {{ic|~/.xmonad/xmonad.hs}} which uses this setup [http://www.haskell.org/haskellwiki/Xmonad/Config_archive/adamvo%27s_xmonad.hs Adamvo's xmonad.hs]
  
 
===Example configurations===
 
===Example configurations===
Line 363: Line 362:
  
 
There are several things that may help:
 
There are several things that may help:
* If you are using {{Pkg|openjdk6}}, you can export {{Ic|_JAVA_AWT_WM_NONREPARENTING<nowiki>=</nowiki>1}} in {{ic|/etc/profile.d/openjdk6.sh}}.
+
* If you are using {{Pkg|jre7-openjdk}}, uncomment the line {{Ic|1=export _JAVA_AWT_WM_NONREPARENTING=1}} in {{ic|/etc/profile.d/jre.sh}}. Then, source the file {{ic|/etc/profile.d/jre.sh}} or log out and log back in.
* If you are using {{Pkg|jre7-openjdk}}, you can export {{Ic|_JAVA_AWT_WM_NONREPARENTING<nowiki>=</nowiki>1}} in {{ic|/etc/profile.d/jre.sh}}.
+
 
* If you are using Oracle's JRE/JDK, the best solution is usually to use [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-SetWMName.html SetWMName.] However, its effect may be nullified if one also uses XMonad.Hooks.EwmhDesktops, in which case
 
* If you are using Oracle's JRE/JDK, the best solution is usually to use [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-SetWMName.html SetWMName.] However, its effect may be nullified if one also uses XMonad.Hooks.EwmhDesktops, in which case
 
   >> setWMName "LG3D"
 
   >> setWMName "LG3D"
Line 379: Line 377:
  
 
===Chromium/Chrome will not go fullscreen===
 
===Chromium/Chrome will not go fullscreen===
If Chrome fails to go fullscreen when {{Keypress|F11}} is pressed, you can use the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html XMonad.Hooks.EwmhDesktops] extension found in the {{Pkg|xmonad-contrib}} package. Simply add the {{ic|import}} statement to your {{ic|~/.xmonad/xmonad.hs}}:
+
If Chrome fails to go fullscreen when {{ic|F11}} is pressed, you can use the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html XMonad.Hooks.EwmhDesktops] extension found in the {{Pkg|xmonad-contrib}} package. Simply add the {{ic|import}} statement to your {{ic|~/.xmonad/xmonad.hs}}:
 
  import XMonad.Hooks.EwmhDesktops
 
  import XMonad.Hooks.EwmhDesktops
  
Line 392: Line 390:
 
</nowiki>}}
 
</nowiki>}}
  
After a recompile/restart of xmonad, Chromium should now respond to {{Keypress|F11}} (fullscreen) as expected.
+
After a recompile/restart of xmonad, Chromium should now respond to {{ic|F11}} (fullscreen) as expected.
  
 
===Multitouch / touchegg===
 
===Multitouch / touchegg===

Revision as of 11:07, 1 September 2013

Tango-preferences-desktop-locale.png本页面需要更新翻译,内容可能已经与英文脱节。要贡献翻译,请访问简体中文翻译组Tango-preferences-desktop-locale.png

附注: please use the first argument of the template to provide more detailed indications.

xmonad 是一个平铺式窗口管理器。窗口会自动填满屏幕,因此能最大化利用屏幕空间。窗口管理器的所有功能都可通过键盘控制,鼠标不是必须的。

xmonad是用Haskell语言写的,对xmonad的配置和扩展也需要使用Haskell语言。名字中的monad是Haskell语言的一个重要特性。窗口布局算法、键盘快捷键和其它扩展都可以通过配置文件(~/.xmonad/xmonad.hs)重新定义。

窗口布局会自适应,不同的工作空间可以使用不同的窗口布局。xmonad完全支持Xinerama,允许窗口平铺至多个物理显示器。

更多信息,请访问xmonad官网: http://xmonad.org/

安装

官方软件库里的xmonadxmonad-contrib是xmonad正式版。AUR里的xmonad-darcsAURxmonad-contrib-darcsAUR是开发版。

安装顺序:

Configuration

启动xmonad

只要添加xmonad命令到启动脚本(如果使用startx则添加到~/.xinitrc文件,如果使用xdm则添加到~/.xsession文件),就能自动运行xmonad。在添加到启动脚本时,exec是可选的,既可以写exec xmonad,也可以写xmonad。GDM和KDM用户可以创建一个新的会话文件,然后从相应的会话菜单选择进入xmonad。

注意: 如果xmonad无法启动,请检查home目录下是否有.xmonad文件夹,没有的话,创建一个:
mkdir ~/.xmonad
注意: xmonad默认不设定鼠标光标,因此光标一直呈“X”形可能会让新用户误以为xmonad还没启动完毕或启动出错。将下面的命令添加到启动脚本,就可以将光标设置成常见的左键头形状:
xsetroot -cursor_name left_ptr

另外,xmonad默认使用US键盘布局,如果想修改为其它键盘布局,比如说德语键盘布局,将以下命令添加到启动脚本,也可以参阅这里

 setxkbmap -layout de

~/.xinitrc文件示例:

 # 设置鼠标光标
 xsetroot -cursor_name left_ptr
 # 设置为德语键盘布局
 setxkbmap -layout de
 # 启动xmonad
 exec xmonad

配置xmonad

xmonad的默认配置文件是~/.xmonad/xmonad.hs,如果~/.xmonad/路径下没有xmonad.hs文件,可以从/usr/share/xmonad-VERSION/man/xmonad.hs拷贝一份。可以通过编辑~/.xmonad/xmonad.hs文件对xmonad进行自定义和扩展。

要使配置生效需要重新编译xmonad,重编译不需要退出xmonad。可以在终端中输入xmonad --recompile,也可以使用快捷键Mod+q进行重编译。Mod默认是Alt键。

因为xmonad配置文件是用Haskell语言写的,非程序员可能会在配置时遇到困难。更多帮助和一些配置文件示例可以从以下链接找到:

自定义配置最好都写在~/.xmonad/xmonad.hs文件里,并且应该把未设置的参数交给内置的defaultConfig处理。

如下面这个示例文件:

 import XMonad
 
 main = do
   xmonad $ defaultConfig
     { terminal    = "urxvt"
     , modMask     = mod4Mask
     , borderWidth = 3
     }

它仅仅将默认终端设置为"urxvt“,Mod键设置为“Windows键”,边框宽度设置为3,其它参数的设置都采用默认值(从defaultConfig函数继承)。

当配置项变多以后,在主函数里将函数名配给参数的做法会更方便。不同的函数置于~/.xmonad/xmonad.hs文件的不同部分。这样的话,大范围的自定义配置会更易于维护。

按照这个思路,上面那个简单的xmonad.hs示例文件,可以写成下面这样:

 import XMonad

 main = do
   xmonad $ defaultConfig
     { terminal    = myTerminal
     , modMask     = myModMask
     , borderWidth = myBorderWidth
     }

 -- 是的,这些也都是函数,只不过是简单函数
 -- 它们不接受输入变量,返回静态值
 myTerminal    = "urxvt"
 myModMask     = mod4Mask -- Windows键或Super_L键
 myBorderWidth = 3

函数(如main, myTerminal, myModMask)的定义顺序或在{}中的顺序是不重要的,只要import语句是在文件起始位置就可以。

下面的例子摘自xmonad 0.9的配置文件模板,完整模板在这里。这个例子包含了经常会在main函数里自定义的项。

 {
   terminal           = myTerminal,
   focusFollowsMouse  = myFocusFollowsMouse,
   borderWidth        = myBorderWidth,
   modMask            = myModMask,
   -- 0.9.1之后已经弃用了numlockMask 
   -- numlockMask        = myNumlockMask,
   workspaces         = myWorkspaces,
   normalBorderColor  = myNormalBorderColor,
   focusedBorderColor = myFocusedBorderColor,

   -- 快捷键
   keys               = myKeys,
   mouseBindings      = myMouseBindings,

   -- 事件钩子、窗口布局
   layoutHook         = myLayout,
   manageHook         = myManageHook,
   handleEventHook    = myEventHook,
   logHook            = myLogHook,
   startupHook        = myStartupHook
 }

推荐参考/usr/share/xmonad-VERSION/man/xmonad.hs文件,它是官方最新的xmonad.hs示例文件,在安装xmonad时自带。

退出xmonad

按下组合键 Mod+Shift+Q 来结束当前的xmonad会话。默认设置下, ModAlt key.

Tips and tricks

Complementary applications

There are number of complementary utilities that work well with xmonad. The most common of these include:

Making room for Conky or tray apps

Wrap your layouts with avoidStruts from XMonad.Hooks.ManageDocks for automatic dock/panel/trayer spacing:

 import XMonad
 import XMonad.Hooks.ManageDocks

 main=do
   xmonad $ defaultConfig
     { ...
     , layoutHook=avoidStruts $ layoutHook defaultConfig
     , manageHook=manageHook defaultConfig <+> manageDocks
     , ...
     }

If you ever want to toggle the gaps, this action can be added to your key bindings:

,((modMask x, xK_b     ), sendMessage ToggleStruts)

Using xmobar with xmonad

xmobar is a light and minimalistic text-based bar, designed to work with xmonad. To use xmobar with xmonad, you will need two packages in addition to the xmonad package. These packages are xmonad-contrib and xmobar from the official repositories, or you can use xmobar-gitAUR from the AUR instead of the official xmobar package.

Here we will start xmobar from within xmonad, which reloads xmobar whenever you reload xmonad.

Open ~/.xmonad/xmonad.hs in your favorite editor, and choose one of the two following options:

Option 1: Quick, less flexible

Note: There is also dzen2 which you can substitute for xmobar in either case.

Common imports:

import XMonad
import XMonad.Hooks.DynamicLog

The xmobar action starts xmobar and returns a modified configuration that includes all of the options described in the xmonad:Option2: More configurable choice.

main = xmonad =<< xmobar defaultConfig { modMask = mod4Mask {- or any other configurations here ... -}}

Option 2: More Configurable

As of xmonad(-contrib) 0.9, there is a new statusBar function in XMonad.Hooks.DynamicLog. It allows you to use your own configuration for:

  • The command used to execute the bar
  • The PP that determines what is being written to the bar
  • The key binding to toggle the gap for the bar

The following is an example of how to use it:

~/.xmonad/xmonad.hs
-- Imports.
import XMonad
import XMonad.Hooks.DynamicLog

-- The main function.
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig

-- Command to launch the bar.
myBar = "xmobar"

-- Custom PP, configure it as you like. It determines what is being written to the bar.
myPP = xmobarPP { ppCurrent = xmobarColor "#429942" "" . wrap "<" ">" }

-- Key binding to toggle the gap for the bar.
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)

-- Main configuration, override the defaults to your liking.
myConfig = defaultConfig { modMask = mod4Mask }

Verify XMobar Config

The template and default xmobarrc contains this.

At last, open up ~/.xmobarrc and make sure you have StdinReader in the template and run the plugin. E.g.

~/.xmobarrc
Config { ...
       , commands = [ Run StdinReader .... ]
         ...
       , template = " %StdinReader% ... "
       }

Now, all you should have to do is either to start, or restart, xmonad.

Controlling xmonad with external scripts

There are at least two ways to do this.

Firstly, you can use the following xmonad extension, XMonad.Hooks.ServerMode.

Secondly, you can simulate keypress events using xdotool or similar programs. See this Ubuntu forums thread. The following command would simulate the keypress Super+n:

xdotool key Super+n

Launching another window manager within xmonad

If you are using xmonad-darcsAUR, as of January of 2011, you can restart to another window manager from within xmonad. You just need to write a small script, and add stuff to your ~/.xmonad/xmonad.hs. Here is the script.

~/bin/obtoxmd
#!/bin/sh
openbox
xmonad

And here are the modifications you need to add to your ~/.xmonad/xmonad.hs:

~/.xmonad/xmonad.hs
import XMonad
--You need to add this import
import XMonad.Util.Replace

main do
    -- And this "replace"
    replace
    xmonad $ defaultConfig
    {
    --Add the usual here
    }

You also need to add the following key binding:

~/xmonad/xmonad.hs
--Add a keybinding as follows:
((modm .|. shiftMask, xK_o     ), restart "/home/abijr/bin/obtoxmd" True)

Just remember to add a comma before or after and change the path to your actual script path. Now just Mod+q (restart xmonad to refresh the config), and then hit Mod+Shift+o and you should have Openbox running with the same windows open as in xmonad. To return to xmonad you should just exit Openbox. Here is a link to adamvo's ~/.xmonad/xmonad.hs which uses this setup Adamvo's xmonad.hs

Example configurations

Below are some example configurations from fellow xmonad users. Feel free to add links to your own.

  • brisbin33 :: complex and simpler branches, importable dzen and scratchpad modules, very readable :: config screenshot
  • jelly :: Configuration with prompt, different layouts, twinview with xmobar :: xmonad.hs
  • MrElendig :: Simple configuration, with xmobar :: xmonad.hs, .xmobarrc, screenshot.
  • thayer :: A minimal mouse-friendly config ideal for netbooks :: configs screenshot
  • vicfryzel :: Beautiful and usable xmonad configuration, along with xmobar configuration, xinitrc, dmenu, and other scripts that make xmonad more usable. :: git repository, screenshot.
  • vogt :: Check out adamvo's config and many others in the official Xmonad/Config archive

Troubleshooting

GNOME 3 and xmonad

With the release of GNOME 3, some additional steps are necessary to make GNOME play nicely with xmonad.

First, add an xmonad session file for use by gnome-session (/usr/share/gnome-session/sessions/xmonad.session):

[GNOME Session]
Name=Xmonad session
RequiredComponents=gnome-panel;gnome-settings-daemon;
RequiredProviders=windowmanager;notifications;
DefaultProvider-windowmanager=xmonad
DefaultProvider-notifications=notification-daemon

Now create a desktop file for GDM (/usr/share/xsessions/xmonad-gnome-session.desktop):

[Desktop Entry]
Name=Xmonad GNOME
Comment=Tiling window manager
TryExec=/usr/bin/gnome-session
Exec=gnome-session --session=xmonad
Type=XSession

Add / edit this file (/usr/share/applications/xmonad.desktop):

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Xmonad
Exec=xmonad
NoDisplay=true
X-GNOME-WMName=Xmonad
X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Provides=windowmanager
X-GNOME-Autostart-Notify=false

Then install xmonad-contrib and create or edit ~/.xmonad/xmonad.hs to have the following

import XMonad
import XMonad.Config.Gnome

main = xmonad gnomeConfig

Xmonad should now appear in the list of GDM sessions and also play nicely with gnome-session itself.

Compositing in Gnome and Xmonad

Some applications look better (e.g. GNOME Do) when composition is enabled. This is, however not, the case in the default Xmonad window manager. To enable it add an additional .desktop file /usr/share/xsessions/xmonad-gnome-session-composite.desktop:

[Desktop Entry]
Name=Xmonad GNOME (Composite)
Comment=Tiling window manager
TryExec=/usr/bin/gnome-session
Exec=/usr/sbin/gnome-xmonad-composite
Type=XSession

And create /usr/sbin/gnome-xmonad-composite and chmod +x /usr/sbin/gnome-xmonad-composite:

xcompmgr &
gnome-session --session=xmonad

Now choose "Xmonad GNOME (Composite)" in the list of sessions during log in. Checkout man xcompmgr for additional "eye candy".

GDM 2.x/KDM cannot find xmonad

You can force GDM to launch xmonad by creating the file xmonad.desktop in the /usr/share/xsessions directory and add the contents:

[Desktop Entry]
Encoding=UTF-8
Name=xmonad
Comment=This session starts xmonad
Exec=/usr/bin/xmonad
Type=Application

Now xmonad will show in your GDM session menu. Thanks to Santanu Chatterjee for the hint.

For KDM, you will need to create the file here as /usr/share/apps/kdm/sessions/xmonad.desktop

Official documentation can be found here: Haskell Documentation Page

Missing xmonad-i386-linux or xmonad-x86_64-linux

Xmonad should automatically create the xmonad-i386-linux file (in ~/.xmonad/). If this it not the case you can grab a cool looking config file from the xmonad wiki or create your own. Put the .hs and all others files in ~/.xmonad/ and run this command from the folder:

xmonad --recompile

Now you should see the file.

Note: A reason you may get an error message saying that xmonad-x86_64-linux is missing is that xmonad-contrib is not installed.

Problems with Java applications

The standard Java GUI toolkit has a hard-coded list of "non-reparenting" window managers. Since xmonad is not in that list, there can be some problems with running some Java applications. One of the most common problems is "gray blobs", when the Java application renders as a plain gray box instead of rendering the GUI.

There are several things that may help:

  • If you are using jre7-openjdk, uncomment the line export _JAVA_AWT_WM_NONREPARENTING=1 in /etc/profile.d/jre.sh. Then, source the file /etc/profile.d/jre.sh or log out and log back in.
  • If you are using Oracle's JRE/JDK, the best solution is usually to use SetWMName. However, its effect may be nullified if one also uses XMonad.Hooks.EwmhDesktops, in which case
 >> setWMName "LG3D"

added to the LogHook may help.

For more details about the problem, refer to the xmonad FAQ.

Empty space at the bottom of gvim or terminals

See Vim#Empty space at the bottom of gvim windows for a solution which makes the area match the background color.

For rxvt-unicode, you can use rxvt-unicode-patchedAUR.

You can also configure xmonad to respect size hints, but this will leave a gap instead. See the documentation on Xmonad.Layout.LayoutHints.

Chromium/Chrome will not go fullscreen

If Chrome fails to go fullscreen when F11 is pressed, you can use the XMonad.Hooks.EwmhDesktops extension found in the xmonad-contrib package. Simply add the import statement to your ~/.xmonad/xmonad.hs:

import XMonad.Hooks.EwmhDesktops

and then add handleEventHook = fullscreenEventHook to the appropriate place; for example:

...
        xmonad $ defaultConfig
            { modMask            = mod4Mask
            , handleEventHook    = fullscreenEventHook
            }
...

After a recompile/restart of xmonad, Chromium should now respond to F11 (fullscreen) as expected.

Multitouch / touchegg

Touchégg polls the window manager for the _NET_CLIENT_LIST (in order to fetch a list of windows it should listen for mouse events on.) By default, xmonad does not supply this property. To enable this, use the XMonad.Hooks.EwmhDesktops extension found in the xmonad-contrib package.

Other Resources