Difference between revisions of "Xmonad"

From ArchWiki
Jump to: navigation, search
(Steam games (Half-Life, Left 4 Dead, …) and xmonad)
(flagged broken section links (interactive))
(Tag: wiki-scripts)
 
(71 intermediate revisions by 31 users not shown)
Line 1: Line 1:
 +
{{Lowercase title}}
 
[[Category:Tiling WMs]]
 
[[Category:Tiling WMs]]
 
[[fr:Xmonad]]
 
[[fr:Xmonad]]
 
[[ja:Xmonad]]
 
[[ja:Xmonad]]
[[tr:Xmonad_Pencere_Yöneticisi]]
+
[[ru:Xmonad]]
 +
[[tr:Xmonad Pencere Yöneticisi]]
 
[[zh-CN:Xmonad]]
 
[[zh-CN:Xmonad]]
 
[http://xmonad.org/ xmonad] is a tiling window manager for X. Windows are arranged automatically to tile the screen without gaps or overlap, maximizing screen use. Window manager features are accessible from the keyboard: a mouse is optional.
 
[http://xmonad.org/ xmonad] is a tiling window manager for X. Windows are arranged automatically to tile the screen without gaps or overlap, maximizing screen use. Window manager features are accessible from the keyboard: a mouse is optional.
  
xmonad is written, configured and extensible in [http://haskell.org/ Haskell]. Custom layout algorithms, key bindings and other extensions may be written by the user in config files.
+
xmonad is written, configured and extensible in [http://haskell.org/ Haskell]. Custom layout algorithms, key bindings and other extensions may be written by the user in configuration files.
  
 
Layouts are applied dynamically, and different layouts may be used on each workspace. Xinerama is fully supported, allowing windows to be tiled on several physical screens.
 
Layouts are applied dynamically, and different layouts may be used on each workspace. Xinerama is fully supported, allowing windows to be tiled on several physical screens.
Line 12: Line 14:
 
For more information, please visit the xmonad website: http://xmonad.org/
 
For more information, please visit the xmonad website: http://xmonad.org/
  
==Installation==
+
== Installation ==
  
{{Pkg|xmonad}} and {{Pkg|xmonad-contrib}} are currently available in the [[Official Repositories|official repositories]]. A build for the current development snapshot (darcs) is in the [[Arch User Repository|AUR]]. The following instructions are for {{AUR|xmonad-darcs}}, the development snapshot.
+
[[Install]] the {{Pkg|xmonad}} package, and possibly {{Pkg|xmonad-contrib}} for third party tiling algorithms, configurations, scripts, etc.
  
===Development version (xmonad-darcs)===
+
Alternatively, install {{AUR|xmonad-git}}, the development version, with some additional dependencies; and likewise {{AUR|xmonad-contrib-git}} if wanted.
  
The xmonad-darcs development version can be installed from the [[Arch User Repository|AUR]], with some additional dependencies in the [[Official Repositories|official repositories]]. [[pacman|Install]] them in the following order:
+
{{Note|If you choose to use the [[ArchHaskell]] repositories, you need to install the ''haskell-xmonad'' package instead of {{Pkg|xmonad}}, as they have different dependencies.}}
  
* {{AUR|xmonad-darcs}} -- The core window manager
+
== Starting xmonad ==
* {{AUR|xmonad-contrib-darcs}} -- Contributed extensions providing custom layouts, configurations, etc.
+
  
==Configuration==
+
Select ''Xmonad'' from the session menu in a [[display manager]] of choice.
  
===Starting xmonad===
+
Alternatively, append {{ic|exec xmonad}} to the {{ic|~/.xinitrc}} file and then start the session by executing ''startx''.
To start xmonad automatically, simply add the command {{Ic|xmonad}} to your startup script (e.g. {{ic|~/.xinitrc}} if you use startx, {{ic|~/.xsession}} if you use xdm login manager). GDM and KDM users can create a new session file and then select xmonad from the appropriate Session menu.
+
  
{{Note|By default, xmonad does not set an X cursor, therefore the "cross" cursor is usually displayed which can be confusing for new users (thinking that xmonad has not launched correctly). To set the expected left-pointer, add the following to your startup file (e.g. {{ic|~/.xinitrc}}):<br>
+
{{Note|By default, xmonad does not set an X cursor, therefore the "cross" cursor is usually displayed. To set the expected left-pointer, see [[Cursor themes#Change X shaped default cursor]].}}
{{bc|xsetroot -cursor_name left_ptr}}}}
+
  
Also, xmonad defaults to the U.S. keyboard layout, so if you want, for example, the German keyboard layout, add the following to {{ic|~/.xinitrc}} or read more about setting keyboard layouts [[Xorg#Keyboard_settings|here]]:
+
== Configuration ==
  setxkbmap -layout de
+
  
Example {{ic|~/.xinitrc}}:
+
Create the {{ic|~/.xmonad}} directory and the {{ic|~/.xmonad/xmonad.hs}} file and edit it as described below.
  # set the cursor
+
  xsetroot -cursor_name left_ptr
+
  # set German keyboard layout
+
  setxkbmap -layout de
+
  # start xmonad
+
  exec xmonad
+
  
If, for some reason, xmonad does not start, check if you have an {{ic|.xmonad}} directory in your home directory. If not, create it:
+
After changes to {{ic|~/.xmonad/xmonad.hs}} are made, use the Mod+q shortcut to recompile and have them take effect.
  mkdir ~/.xmonad
+
  
See [[xinitrc]] for details, such as preserving the logind (and/or consolekit) session.
+
{{Tip|The default configuration for xmonad is quite usable and it is achieved by simply running without an {{ic|xmonad.hs}} entirely.}}
  
===Configuring xmonad===
+
Because the xmonad configuration file is written in Haskell, non-programmers may have a difficult time adjusting settings.  For detailed HOWTO's and example configurations, we refer you to the following resources:
  
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.
+
* [http://wiki.haskell.org/Xmonad xmonad wiki]
 
+
* [http://wiki.haskell.org/Xmonad/Config_archive xmonad configuration archive]
If you find you do not have a directory at {{ic|~/.xmonad}}, run {{Ic|xmonad --recompile}} to create it.
+
* [http://wiki.haskell.org/Xmonad/Frequently_asked_questions xmonad FAQ]
 
+
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.
+
 
+
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/Config_archive xmonad config archive]
+
* [http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions xmonad FAQ]
+
 
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=40636 forum thread]
 
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=40636 forum thread]
  
Line 66: Line 49:
 
This is achieved by writing an {{ic|xmonad.hs}} like this:
 
This is achieved by writing an {{ic|xmonad.hs}} like this:
  
  import XMonad
+
import XMonad
 
+
  main = xmonad defaultConfig
+
main = xmonad defaultConfig
      { terminal    = "urxvt"
+
    { terminal    = "urxvt"
      , modMask    = mod4Mask
+
    , modMask    = mod4Mask
      , borderWidth = 3
+
    , borderWidth = 3
      }
+
    }
  
This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the function defaultConfig).
+
This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the XConfig value 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.
 
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.
Line 80: Line 63:
 
The simple {{ic|xmonad.hs}} from above could have been written like this:
 
The simple {{ic|xmonad.hs}} from above could have been written like this:
  
  import XMonad
+
import XMonad
 
   
 
   
  main = do
+
main = do
    xmonad $ defaultConfig
+
  xmonad $ defaultConfig
      { terminal    = myTerminal
+
    { terminal    = myTerminal
      , modMask    = myModMask
+
    , modMask    = myModMask
      , borderWidth = myBorderWidth
+
    , borderWidth = myBorderWidth
      }
+
    }
 
   
 
   
  -- yes, these are functions; just very simple ones
+
myTerminal    = "urxvt"
  -- that accept no input and return static values
+
myModMask    = mod4Mask -- Win key or Super_L
  myTerminal    = "urxvt"
+
myBorderWidth = 3
  myModMask    = mod4Mask -- Win key or Super_L
+
  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.
 
Also, order at top level (main, myTerminal, myModMask etc.), or within the {} does not matter in Haskell, as long as imports come first.
  
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.
+
The following is taken from the 0.9 configuration file template. It is an example of the most common functions one might want to define in their main do block.
 
   
 
   
  {
+
{
    terminal          = myTerminal,
+
  terminal          = myTerminal,
    focusFollowsMouse  = myFocusFollowsMouse,
+
  focusFollowsMouse  = myFocusFollowsMouse,
    borderWidth        = myBorderWidth,
+
  borderWidth        = myBorderWidth,
    modMask            = myModMask,
+
  modMask            = myModMask,
    -- numlockMask deprecated in 0.9.1
+
  -- numlockMask deprecated in 0.9.1
    -- numlockMask        = myNumlockMask,
+
  -- numlockMask        = myNumlockMask,
    workspaces        = myWorkspaces,
+
  workspaces        = myWorkspaces,
    normalBorderColor  = myNormalBorderColor,
+
  normalBorderColor  = myNormalBorderColor,
    focusedBorderColor = myFocusedBorderColor,
+
  focusedBorderColor = myFocusedBorderColor,
 
   
 
   
    -- key bindings
+
  -- key bindings
    keys              = myKeys,
+
  keys              = myKeys,
    mouseBindings      = myMouseBindings,
+
  mouseBindings      = myMouseBindings,
 
   
 
   
    -- hooks, layouts
+
  -- hooks, layouts
    layoutHook        = myLayout,
+
  layoutHook        = myLayout,
    manageHook        = myManageHook,
+
  manageHook        = myManageHook,
    handleEventHook    = myEventHook,
+
  handleEventHook    = myEventHook,
    logHook            = myLogHook,
+
  logHook            = myLogHook,
    startupHook        = myStartupHook
+
  startupHook        = myStartupHook
   }
+
}
 +
 +
The package itself also includes a {{ic|xmonad.hs}}, which is the latest official example {{ic|xmonad.hs}} that comes with the '''xmonad''' Haskell module as an example of how to override everything. This should not be used as a template configuration, but as examples of parts you can pick to use in your own configuration. It is located in an architecture and version dependant directory in {{ic|/usr/share/}} (e.g. {{ic|find /usr/share -name xmonad.hs}}).
 +
 
 +
=== A base desktop configuration ===
 +
In {{Pkg|xmonad-contrib}} is a better default configuration for average desktop uses. It is also helps with problems in some modern programs like Chromium.
 +
 
 +
It can be added like so:
 +
 
 +
import XMonad
 +
import XMonad.Config.Desktop
 +
 +
baseConfig = desktopConfig
 +
 +
main = xmonad baseConfig
 +
    { terminal    = "urxvt"
 +
    , modMask    = mod4Mask
 +
    }
 +
 
 +
== Exiting xmonad ==
 +
 
 +
To end the current xmonad session, press {{ic|Mod+Shift+Q}}. By default, {{ic|Mod}} is the {{ic|Alt}} key.
 +
 
 +
== Tips and tricks ==
 +
 
 +
=== X-Selection-Paste ===
 +
 
 +
The keyboard-centered operation in Xmonad can be further supported with a keyboard shortcut for [[Keyboard shortcuts#Key binding for X-selection-paste|X-Selection-Paste]].
 +
 
 +
Also, there exists a function "pasteSelection" in XMonad.Util.Paste that can be bound to a key using a line like:
 +
{{hc|xmonad.hs|
 +
   -- X-selection-paste buffer
 +
  , ((0, xK_Insert), pasteSelection)}}
 +
Pressing the "Insert" key will now paste the mouse buffer in the active window.
 +
 
 +
=== Keyboard shortcuts ===
  
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.
+
If you use Xmonad as a stand alone window manager, you can edit the xmonad.hs to add unbound keyboard keys. You just need to find the Xf86 name of the key (such as XF86PowerDown) and look it up in {{Ic|/usr/include/X11/XF86keysym.h}}. It will give you a keycode (like 0x1008FF2A) which you can use to add a line like the following in the keybindings section of your {{ic|xmonad.hs}}:
  
===Exiting xmonad===
+
((0,               0x1008FF2A), spawn "sudo pm-suspend")
To end the current xmonad session, press {{Keypress|Mod+Shift+Q}}. By default, {{Keypress|Mod}} is the {{Keypress|Alt}} key.
+
  
==Tips and tricks==
+
=== Complementary applications ===
The keyboard-centered operation in Xmonad can be further supported with a keyboard shortcut for [[Keyboard_Shortcuts#Key_Binding_for_X-Selection-Paste|X-Selection-Paste]].
+
  
===Complementary applications===
 
 
There are number of complementary utilities that work well with xmonad. The most common of these include:
 
There are number of complementary utilities that work well with xmonad. The most common of these include:
  
* [[dmenu]]
+
* {{App|[[xmobar]]|A lightweight, text-based, status bar written in Haskell.|http://projects.haskell.org/xmobar/|{{Pkg|xmobar}}, {{AUR|xmobar-git}}}}
* [[xmobar]]
+
* {{App|xmonad-log-applet|https://github.com/alexkay/xmonad-log-applet|An applet for the GNOME, MATE or xfce panel.|{{AUR|xmonad-log-applet-xfce4-git}}{{Broken package link|{{aur-mirror|xmonad-log-applet-xfce4-git}}}}, {{AUR|xmonad-log-applet-gnome-git}}{{Broken package link|{{aur-mirror|xmonad-log-applet-gnome-git}}}}}}
* [[dzen]]
+
 
* [[Conky]] and {{AUR|conky-cli}}
+
=== Increase the number of workspaces ===
* [[gmrun]]
+
 
* [[Unclutter]] - a small utility to hide the mouse pointer
+
By default, xmonad uses 9 workspaces.  You can increase this by using something like this:
* [http://uhsure.com/xmonad-log-applet.html XMonad-log-applet] - a GNOME applet for the gnome-panel (the package is in the [[Official Repositories]])
+
  
===Increase the number of workspaces===
 
By default, xmonad uses 9 workspaces.  You can increase this to 14 by extending the following line like this:
 
 
{{hc|xmonad.hs|
 
{{hc|xmonad.hs|
-- (i, k) <- zip (XMonad.workspaces conf) [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9]
+
<nowiki>import XMonad
(i, k) <- zip (XMonad.workspaces conf) [xK_grave, xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9, xK_0, xK_minus, xK_equal, xK_BackSpace]}}
+
import XMonad.Util.EZConfig (additionalKeys)
 +
 
 +
main=do
 +
  xmonad $ defaultConfig
 +
    { ...
 +
    , workspaces = myWorkspaces
 +
    , ...
 +
    } `additionalKeys` myAdditionalKeys
 +
 
 +
myWorkspaces = ["1","2","3","4","5","6","7","8","9"] ++ (map snd myExtraWorkspaces) -- you can customize the names of the default workspaces by changing the list
 +
 
 +
myExtraWorkspaces = [(xK_0, "0")] -- list of (key, name)
 +
 
 +
myAdditionalKeys =
 +
    [ -- ... your other hotkeys ...
 +
    ] ++ [
 +
        ((myModMask, key), (windows $ W.greedyView ws))
 +
        | (key, ws) <- myExtraWorkspaces
 +
    ] ++ [
 +
        ((myModMask .|. shiftMask, key), (windows $ W.shift ws))
 +
        | (key, ws) <- myExtraWorkspaces
 +
    ]</nowiki>
 +
}}
 +
 
 +
=== Making room for Conky or tray apps ===
  
===Making room for Conky or tray apps===
 
 
Wrap your layouts with avoidStruts from XMonad.Hooks.ManageDocks for automatic dock/panel/trayer spacing:
 
Wrap your layouts with avoidStruts from XMonad.Hooks.ManageDocks for automatic dock/panel/trayer spacing:
  
  import XMonad
+
import XMonad
  import XMonad.Hooks.ManageDocks
+
import XMonad.Hooks.ManageDocks
 
   
 
   
  main=do
+
main=do
    xmonad $ defaultConfig
+
  xmonad $ defaultConfig
      { ...
+
    { ...
      , layoutHook=avoidStruts $ layoutHook defaultConfig
+
    , layoutHook=avoidStruts $ layoutHook defaultConfig
      , manageHook=manageHook defaultConfig <+> manageDocks
+
    , manageHook=manageHook defaultConfig <+> manageDocks
      , ...
+
    , ...
      }
+
    }
  
 
If you ever want to toggle the gaps, this action can be added to your key bindings:
 
If you ever want to toggle the gaps, this action can be added to your key bindings:
 
  ,((modMask x, xK_b    ), sendMessage ToggleStruts)
 
  ,((modMask x, xK_b    ), sendMessage ToggleStruts)
  
===Using xmobar with xmonad===
+
=== Using xmobar with xmonad ===
 +
 
 +
{{Merge|xmobar|Make use of the separate article available}}
 +
 
 
'''[[xmobar]]''' is a light and minimalistic text-based bar, designed to work 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 {{Pkg|xmonad}} package. These packages are {{Pkg|xmonad-contrib}} and {{Pkg|xmobar}} from the [[Official Repositories|official repositories]], or you can use {{AUR|xmobar-git}} from the [[Arch User Repository|AUR]] instead of the official {{Pkg|xmobar}} package.
+
To use xmobar with xmonad, you will need two packages in addition to the {{Pkg|xmonad}} package. These packages are {{Pkg|xmonad-contrib}} and {{Pkg|xmobar}} from the [[official repositories]], or you can use {{AUR|xmobar-git}} from the [[AUR]] instead of the official {{Pkg|xmobar}} package.
  
 
Here we will start xmobar from within xmonad, which reloads xmobar whenever you reload xmonad.
 
Here we will start xmobar from within xmonad, which reloads xmobar whenever you reload xmonad.
Line 172: Line 208:
 
Open {{ic|~/.xmonad/xmonad.hs}} in your favorite editor, and choose one of the two following options:
 
Open {{ic|~/.xmonad/xmonad.hs}} in your favorite editor, and choose one of the two following options:
  
====Option 1: Quick, less flexible====
+
==== Quick, less flexible ====
 +
 
 
{{Note|There is also {{Pkg|dzen2}} which you can substitute for {{Pkg|xmobar}} in either case.}}
 
{{Note|There is also {{Pkg|dzen2}} which you can substitute for {{Pkg|xmobar}} in either case.}}
  
Line 179: Line 216:
 
  import XMonad.Hooks.DynamicLog
 
  import XMonad.Hooks.DynamicLog
  
The xmobar action starts xmobar and returns a modified configuration that includes all of the options described in the [[xmonad#Option 2: More configurable|xmonad:Option2: More configurable]] choice.
+
The xmobar action starts xmobar and returns a modified configuration that includes all of the options described in [[#More configurable]].
 
  main = xmonad =<< xmobar defaultConfig { modMask = mod4Mask {- or any other configurations here ... -}}
 
  main = xmonad =<< xmobar defaultConfig { modMask = mod4Mask {- or any other configurations here ... -}}
  
==== Option 2: More Configurable ====
+
==== More configurable ====
 +
 
 
As of xmonad(-contrib) 0.9, there is a new [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#v%3AstatusBar statusBar] function in [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html XMonad.Hooks.DynamicLog]. It allows you to use your own configuration for:
 
As of xmonad(-contrib) 0.9, there is a new [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#v%3AstatusBar statusBar] function in [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html XMonad.Hooks.DynamicLog]. It allows you to use your own configuration for:
 
* The command used to execute the bar
 
* The command used to execute the bar
Line 210: Line 248:
 
</nowiki>}}
 
</nowiki>}}
  
==== Verify XMobar Config ====
+
==== Verify XMobar config ====
 +
 
 
The template and default xmobarrc contains this.
 
The template and default xmobarrc contains this.
  
Line 224: Line 263:
 
Now, all you should have to do is either to start, or restart, xmonad.
 
Now, all you should have to do is either to start, or restart, xmonad.
  
===Controlling xmonad with external scripts===
+
=== Controlling xmonad with external scripts ===
There are at least two ways to do this.
+
Here are a few ways to do it,
  
Firstly, you can use the following xmonad extension, [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ServerMode.html XMonad.Hooks.ServerMode].
+
* 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}}:
+
* 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
  
===Launching another window manager within xmonad===
+
* {{Pkg|wmctrl}} -If you have desktopConfig or EwmhDesktops configured, this is a very easy to use and standard utility.
If you are using {{AUR|xmonad-darcs}}, 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 {{ic|~/.xmonad/xmonad.hs}}. Here is the script.
+
 
 +
=== Launching another window manager within xmonad ===
 +
 
 +
If you are using {{AUR|xmonad-git}}, 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 {{ic|~/.xmonad/xmonad.hs}}. Here is the script.
  
 
{{hc|~/bin/obtoxmd|<nowiki>
 
{{hc|~/bin/obtoxmd|<nowiki>
Line 264: Line 306:
 
</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 configuration), 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://wiki.haskell.org/Xmonad/Config_archive/adamvo%27s_xmonad.hs Adamvo's xmonad.hs]
 +
 
 +
=== KDE and xmonad ===
 +
 
 +
The xmonad wiki has instructions on how to [https://wiki.haskell.org/Xmonad/Using_xmonad_in_KDE run xmonad inside KDE]
 +
 
 +
It also might be a good idea to set a global keyboard shortcut in KDE to start xmonad in case it is accidentally killed or closed.
 +
 
 +
=== IM Layout for Skype ===
 +
 
 +
In orded to create an IM layout for the newer versions of skype, the following code can be used:
 +
{{hc|xmonad.hs|<nowiki>
 +
myIMLayout = withIM (1%7) skype Grid
 +
    where
 +
      skype = And (ClassName "Skype") (Role "")
 +
</nowiki>}}
 +
 
 +
=== Example configurations ===
  
===Example configurations===
 
 
Below are some example configurations from fellow xmonad users.  Feel free to add links to your own.
 
Below are some example configurations from fellow xmonad users.  Feel free to add links to your own.
 +
 
* brisbin33 :: simple, useful, readable :: [https://github.com/pbrisbin/xmonad-config config] [http://files.pbrisbin.com/screenshots/current_desktop.png screenshot]
 
* brisbin33 :: simple, useful, readable :: [https://github.com/pbrisbin/xmonad-config config] [http://files.pbrisbin.com/screenshots/current_desktop.png screenshot]
 
* jelly :: Configuration with prompt, different layouts, twinview with xmobar :: [http://github.com/jelly/dotfiles/tree/master/.xmonad/xmonad.hs xmonad.hs]
 
* jelly :: Configuration with prompt, different layouts, twinview with xmobar :: [http://github.com/jelly/dotfiles/tree/master/.xmonad/xmonad.hs xmonad.hs]
 
* MrElendig :: Simple configuration, with xmobar :: [http://github.com/MrElendig/dotfiles-alice/blob/master/.xmonad/xmonad.hs xmonad.hs], [http://github.com/MrElendig/dotfiles-alice/blob/master/.xmobarrc .xmobarrc], [http://arch.har-ikkje.net/gfx/ss/2010-09-05-163305_2960x1050_scrot.png screenshot].
 
* MrElendig :: Simple configuration, with xmobar :: [http://github.com/MrElendig/dotfiles-alice/blob/master/.xmonad/xmonad.hs xmonad.hs], [http://github.com/MrElendig/dotfiles-alice/blob/master/.xmobarrc .xmobarrc], [http://arch.har-ikkje.net/gfx/ss/2010-09-05-163305_2960x1050_scrot.png screenshot].
* thayer :: A minimal mouse-friendly config ideal for netbooks :: [http://haskell.org/haskellwiki/Xmonad/Config_archive/Thayer_Williams%27_xmonad.hs configs] [http://haskell.org/haskellwiki/Image:Thayer-xmonad-20110511.png screenshot]
+
* thayer :: A minimal mouse-friendly config ideal for netbooks :: [http://wiki.haskell.org/Xmonad/Config_archive/Thayer_Williams%27_xmonad.hs configs] [http://wiki.haskell.org/Image:Thayer-xmonad-20110511.png screenshot]
 
* vicfryzel :: Beautiful and usable xmonad configuration, along with xmobar configuration, xinitrc, dmenu, and other scripts that make xmonad more usable. :: [https://github.com/vicfryzel/xmonad-config git repository], [https://github.com/vicfryzel/xmonad-config/raw/master/screenshot.png screenshot].
 
* vicfryzel :: Beautiful and usable xmonad configuration, along with xmobar configuration, xinitrc, dmenu, and other scripts that make xmonad more usable. :: [https://github.com/vicfryzel/xmonad-config git repository], [https://github.com/vicfryzel/xmonad-config/raw/master/screenshot.png screenshot].
* vogt :: Check out adamvo's config and many others in the official [http://haskell.org/haskellwiki/Xmonad/Config_archive Xmonad/Config archive]
+
* vogt :: Check out adamvo's config and many others in the official [http://wiki.haskell.org/Xmonad/Config_archive Xmonad/Config archive]
 +
* wulax :: Example of using xmonad inside Xfce. Contains two layouts for GIMP. :: [https://gist.github.com/jsjolund/94f6821b248ff79586ba  xmonad.hs], [https://i.imgur.com/at9AbOl.png screenshot].
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== GNOME 3 and xmonad ===
 +
{{accuracy|This no longer works with GNOME. It might still work with [[GNOME Flashback]].}}
  
==Troubleshooting==
+
With the release of GNOME 3 [[GNOME#Custom GNOME sessions|custom GNOME sessions]]{{Broken section link}} require additional steps to make GNOME play nicely with xmonad.  
===GNOME 3 and xmonad===
+
With the release of [[GNOME]] 3, some additional steps are necessary to make GNOME play nicely with xmonad.
+
  
Either install {{AUR|xmonad-gnome3}} from the AUR, or, manually:
+
Either install {{AUR|xmonad-gnome3}}{{Broken package link|{{aur-mirror|xmonad-gnome3}}}} from the AUR, or, manually:
  
 
Add an xmonad session file for use by gnome-session ({{ic|/usr/share/gnome-session/sessions/xmonad.session}}):
 
Add an xmonad session file for use by gnome-session ({{ic|/usr/share/gnome-session/sessions/xmonad.session}}):
Line 328: Line 391:
  
 
==== Compositing in GNOME and Xmonad ====
 
==== 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 {{ic|/usr/share/xsessions/xmonad-gnome-session-composite.desktop}}:
 
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 {{ic|/usr/share/xsessions/xmonad-gnome-session-composite.desktop}}:
 
{{bc|1=
 
{{bc|1=
Line 339: Line 403:
  
 
And create {{ic|/usr/sbin/gnome-xmonad-composite}} and {{ic|chmod +x /usr/sbin/gnome-xmonad-composite}}:
 
And create {{ic|/usr/sbin/gnome-xmonad-composite}} and {{ic|chmod +x /usr/sbin/gnome-xmonad-composite}}:
 +
 
{{bc|1=
 
{{bc|1=
 
xcompmgr &
 
xcompmgr &
 
gnome-session --session=xmonad
 
gnome-session --session=xmonad
 
}}
 
}}
 +
 
Now choose "Xmonad GNOME (Composite)" in the list of sessions during login. Reference {{ic|man xcompmgr}} for additional "eye candy".
 
Now choose "Xmonad GNOME (Composite)" in the list of sessions during login. Reference {{ic|man xcompmgr}} for additional "eye candy".
  
===GDM 2.x/KDM cannot find xmonad===
+
=== Xfce 4 and xmonad ===
You can force GDM to launch xmonad by creating the file {{ic|xmonad.desktop}} in the {{ic|/usr/share/xsessions}} directory and add the contents:
+
  
[Desktop Entry]
+
Use {{ic|xfceConfig}} instead of {{ic|defaultConfig}} after importing {{ic|XMonad.Config.Xfce}} in {{ic|~/.xmonad/xmonad.hs}}, e.g. adapting the minimal configuration above:
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 [http://santanuchatterjee.blogspot.com/2009/03/making-xmonad-to-show-up-in-gdm-session.html Santanu Chatterjee] for the hint.
+
import XMonad
 +
import XMonad.Config.Xfce
 +
 +
main = xmonad xfceConfig
 +
    { terminal    = "urxvt"
 +
    , modMask    = mod4Mask
 +
    }
  
For KDM, you will need to create the file here as {{ic|/usr/share/apps/kdm/sessions/xmonad.desktop}}
+
Also add an entry to ''Settings > Session and Startup > Application Autostart'' that runs {{ic|xmonad --replace}}.
  
Official documentation can be found here:
+
=== Missing xmonad-i386-linux or xmonad-x86_64-linux ===
[http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions#How_can_I_use_xmonad_with_a_display_manager.3F_.28xdm.2C_kdm.2C_gdm.29 Haskell Documentation Page]
+
  
===Missing xmonad-i386-linux or xmonad-x86_64-linux===
+
Xmonad should automatically create the {{ic|xmonad-i386-linux}} file (in {{ic|~/.xmonad/}}). If this it not the case, grab a configuration file from the [http://wiki.haskell.org/Xmonad/Config_archive xmonad wiki] or create your [http://wiki.haskell.org/Xmonad/Config_archive/John_Goerzen's_Configuration own]. Put the {{ic|.hs}} and all others files in {{ic|~/.xmonad/}} and run this command from the folder:
Xmonad should automatically create the {{ic|xmonad-i386-linux}} file (in {{ic|~/.xmonad/}}). If this it not the case you can grab a cool looking config file from the [http://haskell.org/haskellwiki/Xmonad/Config_archive xmonad wiki] or create your [http://haskell.org/haskellwiki/Xmonad/Config_archive/John_Goerzen's_Configuration own]. Put the {{ic|.hs}} and all others files in {{ic|~/.xmonad/}} and run this command from the folder:
+
 
  xmonad --recompile
 
  xmonad --recompile
  
Line 370: Line 434:
 
{{Note|A reason you may get an error message saying that xmonad-x86_64-linux is missing is that {{Pkg|xmonad-contrib}} is not installed.}}
 
{{Note|A reason you may get an error message saying that xmonad-x86_64-linux is missing is that {{Pkg|xmonad-contrib}} is not installed.}}
  
===Problems with Java applications===
+
=== 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.
+
If you have problems, like Java application Windows not resizing, or menus immediately closing after you click, see [[Java#Applications not resizing with WM, menus immediately closing]].
 
+
There are several things that may help:
+
* 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 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"
+
added to the LogHook may help.
+
  
For more details about the problem, refer to the [http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions#Problems_with_Java_applications.2C_Applet_java_console xmonad FAQ.]
+
=== Empty space at the bottom of gvim or terminals ===
 
+
===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.
 
See [[Vim#Empty space at the bottom of gVim windows]] for a solution which makes the area match the background color.
  
Line 388: Line 444:
 
You can also configure xmonad to respect size hints, but this will leave a gap instead. See [http://www.eng.uwaterloo.ca/~aavogt/xmonad/docs/xmonad-contrib/XMonad-Layout-LayoutHints.html the documentation on Xmonad.Layout.LayoutHints].
 
You can also configure xmonad to respect size hints, but this will leave a gap instead. See [http://www.eng.uwaterloo.ca/~aavogt/xmonad/docs/xmonad-contrib/XMonad-Layout-LayoutHints.html the documentation on Xmonad.Layout.LayoutHints].
  
===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 402: Line 458:
 
</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 ===
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 [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html XMonad.Hooks.EwmhDesktops] extension found in the {{Pkg|xmonad-contrib}} package.
+
 
 +
Touchégg polls the window manager for the {{ic|_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 [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html XMonad.Hooks.EwmhDesktops] extension found in the {{Pkg|xmonad-contrib}} package.
 +
 
 +
=== Keybinding issues with an azerty keyboard layout ===
  
===Keybinding issues with an azerty keyboard layout===
 
 
Users with a keyboard with azerty layout can run into issues with certain keybindings. Using the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Config-Azerty.html XMonad.Config.Azerty] module will solve this.
 
Users with a keyboard with azerty layout can run into issues with certain keybindings. Using the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Config-Azerty.html XMonad.Config.Azerty] module will solve this.
  
===GNOME 3 mod4+p changes display configuration instead of launching dmenu===
+
=== GNOME 3 mod4+p changes display configuration instead of launching dmenu ===
 +
 
 
If you do not need the capability to switch the display-setup in the gnome-control-center, just execute
 
If you do not need the capability to switch the display-setup in the gnome-control-center, just execute
 
{{bc|<nowiki>dconf write /org/gnome/settings-daemon/plugins/xrandr/active false</nowiki>}}
 
{{bc|<nowiki>dconf write /org/gnome/settings-daemon/plugins/xrandr/active false</nowiki>}}
 
as your user, to disable the xrandr plugin which grabs Super+p.
 
as your user, to disable the xrandr plugin which grabs Super+p.
  
===Problems with focused border in VirtualBox===
+
=== Problems with focused border in VirtualBox ===
 +
 
 
A known issue with Virtualbox ([https://www.virtualbox.org/ticket/6479 Ticket #6479]) can cause problems with the focused window border. A solution can be found by installing a compositing manager like [[xcompmgr]] which overrides the incorrect behavior of vboxvideo.
 
A known issue with Virtualbox ([https://www.virtualbox.org/ticket/6479 Ticket #6479]) can cause problems with the focused window border. A solution can be found by installing a compositing manager like [[xcompmgr]] which overrides the incorrect behavior of vboxvideo.
  
===Steam games (Half-Life, Left 4 Dead, …) and xmonad===
+
=== Steam games (Half-Life, Left 4 Dead, …) and xmonad ===
There seems to be some trouble with Source engine based game (like Half-Life). If they don't start or get stuck with a black screen a workaround it to start them in window mode: right click on the game in your library and choose properties, click on launch options and enter  
+
 
 +
There seems to be some trouble with xmonad and Source engine based games like Half-Life. If they do not start or get stuck with a black screen, a workaround is to start them in windowed mode. To do so, right click on the game in your Steam library and choose properties, click on launch options and enter [http://steamcommunity.com/app/221410/discussions/0/864960353968561426/]:
 +
 
  -windowed
 
  -windowed
That should fix the issue.
 
  
Source: http://steamcommunity.com/app/221410/discussions/0/864960353968561426/
+
Another solution is to float the window of the game using the manage hook. For example, the following line can be used for Half-Life:
 +
 
 +
  className =? "hl_linux" --> doFloat
 +
 
 +
This can also be worked around by making XMonad pay attention to EWMH hints and including its fullscreen hook [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html]:
 +
 
 +
  main = xmonad $ ewmh defaultConfig{ handleEventHook =
 +
            handleEventHook defaultConfig <+> fullscreenEventHook }
 +
 
 +
This has a few other effects and makes it behave more akin to fullscreen apps in other WMs.
 +
 
 +
=== LibreOffice - focus flicking between main window and dialog ===
 +
 
 +
The LibreOffice UI defaults to the gtk engine outside a desktop environment. This may cause problems with some xmonad configurations resulting in focus rapidly flicking between the LibreOffice main window and any open LibreOffice dialog window. Effectively locking the application. In this case the environment variable SAL_USE_VCLPLUGIN can be set to explicitly force LibreOffice to use another UI theme as outlined in [[LibreOffice#Theme]] For instance
 +
 
 +
  export SAL_USE_VCLPLUGIN=gen lowriter
 +
 
 +
to use the general (QT) UI.
 +
 
 +
== See also ==
  
==Other Resources==
 
 
*[http://xmonad.org/ xmonad] - The official xmonad website
 
*[http://xmonad.org/ xmonad] - The official xmonad website
*[http://haskell.org/haskellwiki/Xmonad/Config_archive/Template_xmonad.hs_(0.9) xmonad.hs] - Template xmonad.hs
+
*[https://wiki.haskell.org/Xmonad/Config_archive/Template_xmonad.hs xmonad.hs] - Template xmonad.hs
 
*[http://xmonad.org/tour.html xmonad: a guided tour]
 
*[http://xmonad.org/tour.html xmonad: a guided tour]
 
*[[dzen]] - General purpose messaging and notification program
 
*[[dzen]] - General purpose messaging and notification program
 
*[[dmenu]] - Dynamic X menu for the quick launching of programs
 
*[[dmenu]] - Dynamic X menu for the quick launching of programs
*[[Comparison of Tiling Window Managers]] - Arch wiki article providing an overview of mainstream tiling window managers
+
*[[Comparison of tiling window managers]] - Arch wiki article providing an overview of mainstream tiling window managers
 
*[https://bbs.archlinux.org/viewtopic.php?id=94969 Share your xmonad desktop!]
 
*[https://bbs.archlinux.org/viewtopic.php?id=94969 Share your xmonad desktop!]
 
*[https://bbs.archlinux.org/viewtopic.php?id=40636 xmonad hacking thread]
 
*[https://bbs.archlinux.org/viewtopic.php?id=40636 xmonad hacking thread]

Latest revision as of 11:00, 7 August 2016

xmonad is a tiling window manager for X. Windows are arranged automatically to tile the screen without gaps or overlap, maximizing screen use. Window manager features are accessible from the keyboard: a mouse is optional.

xmonad is written, configured and extensible in Haskell. Custom layout algorithms, key bindings and other extensions may be written by the user in configuration files.

Layouts are applied dynamically, and different layouts may be used on each workspace. Xinerama is fully supported, allowing windows to be tiled on several physical screens.

For more information, please visit the xmonad website: http://xmonad.org/

Installation

Install the xmonad package, and possibly xmonad-contrib for third party tiling algorithms, configurations, scripts, etc.

Alternatively, install xmonad-gitAUR, the development version, with some additional dependencies; and likewise xmonad-contrib-gitAUR if wanted.

Note: If you choose to use the ArchHaskell repositories, you need to install the haskell-xmonad package instead of xmonad, as they have different dependencies.

Starting xmonad

Select Xmonad from the session menu in a display manager of choice.

Alternatively, append exec xmonad to the ~/.xinitrc file and then start the session by executing startx.

Note: By default, xmonad does not set an X cursor, therefore the "cross" cursor is usually displayed. To set the expected left-pointer, see Cursor themes#Change X shaped default cursor.

Configuration

Create the ~/.xmonad directory and the ~/.xmonad/xmonad.hs file and edit it as described below.

After changes to ~/.xmonad/xmonad.hs are made, use the Mod+q shortcut to recompile and have them take effect.

Tip: The default configuration for xmonad is quite usable and it is achieved by simply running without an xmonad.hs entirely.

Because the xmonad configuration file is written in Haskell, non-programmers may have a difficult time adjusting settings. For detailed HOWTO's and example configurations, we refer you to the following resources:

The best approach is to only place your changes and customizations in ~/.xmonad/xmonad.hs and write it such that any unset parameters are picked up from the built-in defaultConfig.

This is achieved by writing an xmonad.hs like this:

import XMonad

main = xmonad defaultConfig
    { terminal    = "urxvt"
    , modMask     = mod4Mask
    , borderWidth = 3
    }

This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the XConfig value 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 ~/.xmonad/xmonad.hs. This makes large customizations like your layout and manage hooks easier to visualize and maintain.

The simple xmonad.hs from above could have been written like this:

import XMonad

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

myTerminal    = "urxvt"
myModMask     = mod4Mask -- Win key or Super_L
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.

The following is taken from the 0.9 configuration file template. It is an example of the most common functions one might want to define in their main do block.

{
  terminal           = myTerminal,
  focusFollowsMouse  = myFocusFollowsMouse,
  borderWidth        = myBorderWidth,
  modMask            = myModMask,
  -- numlockMask deprecated in 0.9.1
  -- numlockMask        = myNumlockMask,
  workspaces         = myWorkspaces,
  normalBorderColor  = myNormalBorderColor,
  focusedBorderColor = myFocusedBorderColor,

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

  -- hooks, layouts
  layoutHook         = myLayout,
  manageHook         = myManageHook,
  handleEventHook    = myEventHook,
  logHook            = myLogHook,
  startupHook        = myStartupHook
}

The package itself also includes a xmonad.hs, which is the latest official example xmonad.hs that comes with the xmonad Haskell module as an example of how to override everything. This should not be used as a template configuration, but as examples of parts you can pick to use in your own configuration. It is located in an architecture and version dependant directory in /usr/share/ (e.g. find /usr/share -name xmonad.hs).

A base desktop configuration

In xmonad-contrib is a better default configuration for average desktop uses. It is also helps with problems in some modern programs like Chromium.

It can be added like so:

import XMonad
import XMonad.Config.Desktop

baseConfig = desktopConfig

main = xmonad baseConfig
    { terminal    = "urxvt"
    , modMask     = mod4Mask
    }

Exiting xmonad

To end the current xmonad session, press Mod+Shift+Q. By default, Mod is the Alt key.

Tips and tricks

X-Selection-Paste

The keyboard-centered operation in Xmonad can be further supported with a keyboard shortcut for X-Selection-Paste.

Also, there exists a function "pasteSelection" in XMonad.Util.Paste that can be bound to a key using a line like:

xmonad.hs
  -- X-selection-paste buffer
  , ((0, xK_Insert), pasteSelection)

Pressing the "Insert" key will now paste the mouse buffer in the active window.

Keyboard shortcuts

If you use Xmonad as a stand alone window manager, you can edit the xmonad.hs to add unbound keyboard keys. You just need to find the Xf86 name of the key (such as XF86PowerDown) and look it up in /usr/include/X11/XF86keysym.h. It will give you a keycode (like 0x1008FF2A) which you can use to add a line like the following in the keybindings section of your xmonad.hs:

((0,               0x1008FF2A), spawn "sudo pm-suspend")

Complementary applications

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

  • xmobar — A lightweight, text-based, status bar written in Haskell.
http://projects.haskell.org/xmobar/ || xmobar, xmobar-gitAUR
An applet for the GNOME, MATE or xfce panel. || xmonad-log-applet-xfce4-gitAUR[broken link: archived in aur-mirror], xmonad-log-applet-gnome-gitAUR[broken link: archived in aur-mirror]

Increase the number of workspaces

By default, xmonad uses 9 workspaces. You can increase this by using something like this:

xmonad.hs
import XMonad
import XMonad.Util.EZConfig (additionalKeys)

main=do
  xmonad $ defaultConfig
    { ...
    , workspaces = myWorkspaces
    , ...
    } `additionalKeys` myAdditionalKeys

myWorkspaces = ["1","2","3","4","5","6","7","8","9"] ++ (map snd myExtraWorkspaces) -- you can customize the names of the default workspaces by changing the list

myExtraWorkspaces = [(xK_0, "0")] -- list of (key, name)

myAdditionalKeys =
    [ -- ... your other hotkeys ...
    ] ++ [
        ((myModMask, key), (windows $ W.greedyView ws))
        | (key, ws) <- myExtraWorkspaces
    ] ++ [
        ((myModMask .|. shiftMask, key), (windows $ W.shift ws))
        | (key, ws) <- myExtraWorkspaces
    ]

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

Merge-arrows-2.pngThis article or section is a candidate for merging with xmobar.Merge-arrows-2.png

Notes: Make use of the separate article available (Discuss in Talk: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:

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 #More configurable.

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

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

Here are a few ways to do it,

  • 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
  • wmctrl -If you have desktopConfig or EwmhDesktops configured, this is a very easy to use and standard utility.

Launching another window manager within xmonad

If you are using xmonad-gitAUR, 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 configuration), 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

KDE and xmonad

The xmonad wiki has instructions on how to run xmonad inside KDE

It also might be a good idea to set a global keyboard shortcut in KDE to start xmonad in case it is accidentally killed or closed.

IM Layout for Skype

In orded to create an IM layout for the newer versions of skype, the following code can be used:

xmonad.hs
myIMLayout = withIM (1%7) skype Grid
    where
      skype = And (ClassName "Skype") (Role "")

Example configurations

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

  • brisbin33 :: simple, useful, 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
  • wulax :: Example of using xmonad inside Xfce. Contains two layouts for GIMP. :: xmonad.hs, screenshot.

Troubleshooting

GNOME 3 and xmonad

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: This no longer works with GNOME. It might still work with GNOME Flashback. (Discuss in Talk:Xmonad#)

With the release of GNOME 3 custom GNOME sessions[broken link: invalid section] require additional steps to make GNOME play nicely with xmonad.

Either install xmonad-gnome3AUR[broken link: archived in aur-mirror] from the AUR, or, manually:

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

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

Create or 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

Finally, 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 login. Reference man xcompmgr for additional "eye candy".

Xfce 4 and xmonad

Use xfceConfig instead of defaultConfig after importing XMonad.Config.Xfce in ~/.xmonad/xmonad.hs, e.g. adapting the minimal configuration above:

import XMonad
import XMonad.Config.Xfce

main = xmonad xfceConfig
    { terminal    = "urxvt"
    , modMask     = mod4Mask
    }

Also add an entry to Settings > Session and Startup > Application Autostart that runs xmonad --replace.

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, grab a configuration 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

If you have problems, like Java application Windows not resizing, or menus immediately closing after you click, see Java#Applications not resizing with WM, menus immediately closing.

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.

Keybinding issues with an azerty keyboard layout

Users with a keyboard with azerty layout can run into issues with certain keybindings. Using the XMonad.Config.Azerty module will solve this.

GNOME 3 mod4+p changes display configuration instead of launching dmenu

If you do not need the capability to switch the display-setup in the gnome-control-center, just execute

dconf write /org/gnome/settings-daemon/plugins/xrandr/active false

as your user, to disable the xrandr plugin which grabs Super+p.

Problems with focused border in VirtualBox

A known issue with Virtualbox (Ticket #6479) can cause problems with the focused window border. A solution can be found by installing a compositing manager like xcompmgr which overrides the incorrect behavior of vboxvideo.

Steam games (Half-Life, Left 4 Dead, …) and xmonad

There seems to be some trouble with xmonad and Source engine based games like Half-Life. If they do not start or get stuck with a black screen, a workaround is to start them in windowed mode. To do so, right click on the game in your Steam library and choose properties, click on launch options and enter [1]:

-windowed

Another solution is to float the window of the game using the manage hook. For example, the following line can be used for Half-Life:

 className =? "hl_linux" --> doFloat

This can also be worked around by making XMonad pay attention to EWMH hints and including its fullscreen hook [2]:

  main = xmonad $ ewmh defaultConfig{ handleEventHook =
           handleEventHook defaultConfig <+> fullscreenEventHook }

This has a few other effects and makes it behave more akin to fullscreen apps in other WMs.

LibreOffice - focus flicking between main window and dialog

The LibreOffice UI defaults to the gtk engine outside a desktop environment. This may cause problems with some xmonad configurations resulting in focus rapidly flicking between the LibreOffice main window and any open LibreOffice dialog window. Effectively locking the application. In this case the environment variable SAL_USE_VCLPLUGIN can be set to explicitly force LibreOffice to use another UI theme as outlined in LibreOffice#Theme For instance

  export SAL_USE_VCLPLUGIN=gen lowriter

to use the general (QT) UI.

See also