Xmonad
lastmod 2025-08-09created 2020-06-2262 edits
xmonad is a dynamically tiling X11 window manager that is written and configured in Haskell. In a normal WM, you spend half your time aligning and searching for windows. xmonad makes work easier, by automating this.
Categories
- xorg
- Haskell
- Xmonad:Config
- Xmonad:Config:darcs - darcs template
xmonad.hs - Xmonad/Config archive/Mntnoe's xmonad.hs - HaskellWiki - Has many good examples.
- Xmonad:Config:darcs - darcs template
Plugins
- XMonad.Actions.TreeSelect
- XMonad.Doc.Extending - Includes a list of extension modules.
- XMonad.Hooks.EwmhDesktops
- XMonad.Hooks.ManageDocks
- XMonad.Util.Scratchpad
- XMonad.Layout - Full
- XMonad.Layout.Accordion
- XMonad.Layout.Combo
- XMonad.Layout.Tabbed
- XMonad.Layout.Gaps
- XMonad.Layout.LayoutCombinators
- XMonad.Layout.NoBorders
- XMonad.Layout.SimpleDecoration
- XMonad.Layout.Spacing
- XMonad.Layout.SubLayouts
- XMonad.Layout.LayoutBuilder
To review
- https://www.youtube.com/watch?v=qQ4CcMTLW-4
- GridSelect
- ToggleStruts
- ToggleBorders
Utilities
Installation
If you use xmonad, install it as follows.
| Note |
| After upgrading, you must run the |
Starting
Run xmonad with xinit.
Bar/Tray
Compositing window manager
Flags
The flags are as follows:
-
--recompile - Recompiles the configuration in
~/.xmonad/xmonad.hs.
-
--restart - Restarts the currently running xmonad process.
-
--replace - Replaces the current window manager with xmonad.
-
--version - Display the xmonad version
-
--verbose-version - Display the detailed xmonad version
Key binding
| |
| |
Default keyboard bindings
-
mod-shift-return - Launch the default terminal
-
mod-p - Launch dmenu
-
mod-shift-p - Launch gmrun
-
mod-shift-c - Close the currently focused window.
-
mod-space - Rotate windows through the available layout algorithms.
-
mod-shift-space - Reset the layout of the current workspace to the default.
-
mod-n - Resize viewed windows to the correct size
-
mod-tab - Move focus to the next window
-
mod-shift-tab - Move focus to the previous window
-
mod-j - Move focus to the next window
-
mod-k - Move focus to the previous window
-
mod-m - Move focus to the master window
-
mod-return - Swap the focused window and the master window
-
mod-shift-j - Swap the focused window with the next window
-
mod-shift-k - Swap the focused window with the previous window
-
mod-h - Shrink the master area
-
mod-l - Expand the master area
-
mod-t - Puts the window back into tiling. Use it when you want to tile a floating window again.
-
mod-comma - Increment the number of windows in the master area
-
mod-period - Deincrement the number of windows in the master area
-
mod-shift-q - Quit xmonad
-
mod-q - Restart xmonad
-
mod-shift-slash - Run xmessage with a summary of the default keybindings (useful for beginners)
-
mod-[1..9] - Switch to workspace N
-
mod-shift-[1..9] - Move client to workspace N
-
mod-{w,e,r} - Switch to physical/Xinerama screens 1, 2, or 3
-
mod-shift-{w,e,r} - Move client to screen 1, 2, or 3
-
mod-button1 - Set the window to floating mode and move by dragging
-
mod-button2 - Raise the window to the top of the stack
-
mod-button3 - Set the window to floating mode and resize by dragging
Customization
xmonad is customized in ~/.xmonad/xmonad.hs, and then restarting with mod-q.
You can find many extensions to the core feature set in the xmonad- contrib package, available through your package manager or from xmonad.org.
Modular Configuration
As of xmonad-0.9, any additional Haskell modules may be placed in ~/.xmonad/lib/ are available in GHC's searchpath. Hierarchical modules are supported: for example, the file ~/.xmonad/lib/XMonad/Stack/MyAdditions.hs could contain:
module XMonad.Stack.MyAdditions (function1) where
function1 = error "function1: Not implemented yet!"
Your xmonad.hs may then import XMonad.Stack.MyAdditions as if that module was contained within xmonad or xmonad-contrib.
List of Tiling window manager
Troubleshooting
Xmonad freezing problem
Xmonad takes the output of windows and writes it to a pipe for logging, and it was blocking because the pipe had filled up. That is why it would block once every few days if I worked steadily in a single window (emacs, etc.), and freeze before long if I switched back and forth between several windows. Meanwhile, xmobar, the status bar of Xmonad, had been configured with StdinReader, which reads stdin and prints it on screen. The problem was that this StdinReader had died.
Looking further into why StdinReader dies, it turns out that hGetLine() cannot handle UTF8 code. Online sources say handling it with System.IO.UTF8.hGetLine fixes it, but when I actually tried it, it still died. After trying various things, I ended up setting the handle to latin1 encoding in xmobar's StdinReader handling code. After that it no longer dies. In the test code below, assuming bar.txt contains a UTF8 string, it kept raising the error hGetLine: invalid argument (Invalid or .... multibyte or wide character) until x was set to latin1.
import IO
import System.IO
import System.IO.UTF8
main = do x <- openFile "/tmp/bar.txt" ReadMode
hSetEncoding x System.IO.latin1
y <- System.IO.UTF8.hGetLine x
IO.putStr y
GNOME with xmonad
The simplest solution to this problem for me was to use
instead of defaultConfig in my ~/.xmonad/xmonad.hs file.
FullScreen SDL Game
- See XMonad.Hooks.EwmhDesktops.
- Full screen games (from Steam) in XMonad invisible / Multimedia and Games / Arch Linux Forums
- Fullscreen SDL apps/games with Xmonad?
I don't play games on my xmonad machines, but maybe this will help. Does SDL use the EWMH fullscreen hint?
I import XMonad.Hooks.EwmhDesktops and then have this in my manage hooks:
I also create an ewmh config object:
And then I compose ewmhConfig into my manage hooks, layout hooks, and event hooks (ewmhDesktopsEventHook). Oh, and I put the fullscreenEventHook also in with the event hooks.
See also
Favorite site
- Xmonad web site
- xmonad - ArchWiki
- Xmonad vs i3 detailed comparison as of 2020 - Slant
- Visual xmonad Layouts Guide | Between Two Commits
- monad/Frequently asked questions - HaskellWiki
- Linux Setup with XMonad
- This is the Xmonad Tutorial for Beginning Beginners — Xmonad Tutorial for Beginning Beginners 1.0 documentation (xmonad, xmobar, stalonetray)
Guide
- My XMonad Configuration · Xiang - Explains good modules.
- Visual xmonad Layouts Guide - Explains various kinds of layers and shows simple configuration.
- ArchLinux:Setup
- Awesome
- Compositing window manager
- Computer Sciences
- Desktop environment
- Display manager
- Dwm
- Haskell
- Hyprland
- I3
- IntelliJ IDEA
- Tiling window manager
- User Interface
- Window Manager
- X Window System
- XMonad.Config
- XMonad.Hooks.EwmhDesktops
- XMonad.Hooks.ManageDocks
- XMonad.Util.Run
- Xmonad:LayoutHook
- Xprop