Xmonad: Difference between revisions
Lahwaacz.bot (talk | contribs) update http to https for known domains |
Undo revision 807193 by KirisameMarisa (talk) - No specific to Xmonad Tag: Undo |
||
(78 intermediate revisions by 20 users not shown) | |||
Line 1: | Line 1: | ||
{{Lowercase title}} | {{Lowercase title}} | ||
[[Category:Tiling | [[Category:Tiling window managers]] | ||
[[de:Xmonad]] | |||
[[fr:Xmonad]] | [[fr:Xmonad]] | ||
[[ja:Xmonad]] | [[ja:Xmonad]] | ||
[[zh-hans:Xmonad]] | [[zh-hans:Xmonad]] | ||
{{Related articles start}} | {{Related articles start}} | ||
Line 10: | Line 10: | ||
{{Related articles end}} | {{Related articles end}} | ||
{{Style|Lots of config dumps, missing hc templates}} | |||
xmonad is written, configured and extensible in [ | [https://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 [https://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. [[Wikipedia:Xinerama|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. [[Wikipedia:Xinerama|Xinerama]] is fully supported, allowing windows to be tiled on several physical screens. | ||
Line 22: | Line 24: | ||
Alternatively, install {{AUR|xmonad-git}}, the development version, with some additional dependencies; and likewise {{AUR|xmonad-contrib-git}}. | Alternatively, install {{AUR|xmonad-git}}, the development version, with some additional dependencies; and likewise {{AUR|xmonad-contrib-git}}. | ||
{{Note|Remember to run {{ic|xmonad --recompile}} after you upgrade xmonad, otherwise it might have problems finding shared libraries the next time you start it.}} | {{Note|Remember to run {{ic|xmonad --recompile}} after you upgrade xmonad, otherwise it might have problems finding shared libraries the next time you start it. To automate this process, see [[#Problems with finding shared libraries after update]].}} | ||
== Starting == | == Starting == | ||
Line 38: | Line 40: | ||
Create the {{ic|~/.xmonad}} directory and the {{ic|~/.xmonad/xmonad.hs}} file and edit it as described below. | Create the {{ic|~/.xmonad}} directory and the {{ic|~/.xmonad/xmonad.hs}} file and edit it as described below. | ||
After changes to {{ic|~/.xmonad/xmonad.hs}} are made, use the Mod+q shortcut to recompile and have them take effect. | After changes to {{ic|~/.xmonad/xmonad.hs}} are made, use the {{ic|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 {{ic|xmonad.hs}} entirely.}} | {{Tip|The default configuration for xmonad is quite usable and it is achieved by simply running without an {{ic|xmonad.hs}} entirely.}} | ||
Line 44: | Line 46: | ||
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: | 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: | ||
* [ | * [https://wiki.haskell.org/Xmonad xmonad wiki] | ||
* [ | * [https://wiki.haskell.org/Xmonad/Config_archive xmonad configuration archive] | ||
* [ | * [https://wiki.haskell.org/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] | ||
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 def function. | 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 ''def'' function. | ||
This is achieved by writing an {{ic|xmonad.hs}} like this: | This is achieved by writing an {{ic|xmonad.hs}} like this: | ||
Line 61: | Line 63: | ||
} | } | ||
This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the XConfig value def). | This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the XConfig value ''def''). | ||
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 110: | Line 112: | ||
=== A base desktop configuration === | === A base desktop configuration === | ||
In {{Pkg|xmonad-contrib}} is a better default configuration for average desktop uses. It also helps with problems in some modern programs like Chromium. | In {{Pkg|xmonad-contrib}} is a better default configuration for average desktop uses. It also helps with problems in some modern programs like Chromium. | ||
Line 125: | Line 128: | ||
To end the current xmonad session, press {{ic|Mod+Shift+Q}}. By default, {{ic|Mod}} is the {{ic|Alt}} key. | To end the current xmonad session, press {{ic|Mod+Shift+Q}}. By default, {{ic|Mod}} is the {{ic|Alt}} key. | ||
To confirm exit each time, | |||
{{hc|xmonad.hs| | |||
<nowiki> | |||
... | |||
import XMonad.Prompt.ConfirmPrompt | |||
... | |||
myKeys :: [(String, X ())] | |||
myKeys = | |||
... | |||
("M-S-q", confirmPrompt defaultXPConfig "exit" $ io exitSuccess) | |||
... | |||
</nowiki> | |||
}} | |||
== Tips and tricks == | == Tips and tricks == | ||
Line 132: | Line 149: | ||
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]]. | 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 | Also, there exists a function {{ic|pasteSelection}} in {{ic|XMonad.Util.Paste}} that can be bound to a key using a line like: | ||
{{hc|xmonad.hs| | {{hc|xmonad.hs| | ||
import XMonad.Util.Paste -- Remember to include this line | import XMonad.Util.Paste -- Remember to include this line | ||
Line 138: | Line 155: | ||
-- X-selection-paste buffer | -- X-selection-paste buffer | ||
, ((0, xK_Insert), pasteSelection)}} | , ((0, xK_Insert), pasteSelection)}} | ||
Pressing the | Pressing the {{ic|Insert}} key will now paste the mouse buffer in the active window. | ||
{{Warning|1=<nowiki/> | |||
* Note that {{ic|pasteSelection}} uses {{ic|getSelection}} from {{ic|XMonad.Util.XSelection}} and so is heir to its flaws. | |||
* {{ic|getSelection}} "is fundamentally implemented incorrectly and may, among other possible failure modes, deadlock or crash". For details, see [https://code.google.com/p/xmonad/issues/detail?id=573]. | |||
* These errors are generally very rare in practice, but still exist.}} | |||
{{Tip|1=<nowiki/>To find out more, see [https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Util-XSelection.html].}} | |||
=== Keyboard shortcuts === | === Keyboard shortcuts === | ||
Default keyboard shortcuts are listed | Default keyboard shortcuts are listed {{man|1|xmonad}}. | ||
=== Targeting unbound keys === | === Targeting unbound keys === | ||
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 | If you use xmonad as a stand alone window manager, you can edit the {{ic|xmonad.hs}} to add unbound keyboard keys. You just need to find the Xf86 name of the key (such as {{ic|XF86PowerDown}}) and look it up in {{Ic|/usr/include/X11/XF86keysym.h}}. It will give you a keycode (like {{ic|0x1008FF2A}}) which you can use to add a line like the following into list of keybindings in your {{ic|xmonad.hs}}: | ||
((0, 0x1008FF2A), spawn "sudo systemctl suspend") | |||
You can also search for the Xf86 key name in [https://hackage.haskell.org/package/X11-1.9.2/docs/Graphics-X11-ExtraTypes-XF86.html Graphics.X11.ExtraTypes.XF86] module, and use its {{ic|KeySym}} constant (such as {{ic|xF86XK_PowerDown}}) instead of a keycode as shown in the previous example. You will also need to import the module in your {{ic|xmonad.hs}} for the key constant to be available. See more elaborate example with multiple keys in format used by {{ic|additionalKeys}} function: | |||
import Graphics.X11.ExtraTypes.XF86 | |||
... | |||
myKeys = [ | |||
((0, xF86XK_PowerDown), spawn "sudo systemctl suspend") | |||
, ((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 10%+") | |||
, ((0, xF86XK_AudioLowerVolume), spawn "amixer -D pulse sset Master 10%-") | |||
, ((0, xF86XK_AudioMute), spawn "amixer -D pulse sset Master toggle") | |||
, ((0, xF86XK_MonBrightnessUp), spawn "brightnessctl set +10%") | |||
, ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 10%-") | |||
... | |||
] | |||
=== Run X () actions by touching the edge of your screen with your mouse === | |||
With [https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Hooks-ScreenCorners.html XMonad.Hooks.ScreenCorners], users can have KDE-like screen corners with XMonad. | |||
==== Switch workspaces with ScreenCorners (KDE-like) ==== | |||
Define a series of operations in startupHook: | |||
{{hc|xmonad.hs| | |||
<nowiki> | |||
... | |||
import XMonad.Hooks.ScreenCorners | |||
... | |||
mystartupHook = do | |||
... | |||
... example ... | |||
addScreenCorners [ (SCLowerLeft, prevWS) | |||
, (SCLowerRight, nextWS) | |||
, (SCUpperLeft, spawnSelected' myAppGrid) | |||
, (SCUpperRight, goToSelected $ mygridConfig' myColorizer) | |||
] | |||
... | |||
</nowiki> | |||
}} | |||
Then add screenCornerEventHook to handleEventHook: | |||
myConfig = def { | |||
... | |||
handleEventHook = ... <+> screenCornerEventHook <+> ... | |||
... | |||
} | |||
Finally add screenCornerLayoutHook: | |||
... | |||
myLayoutHook = screenCornerLayoutHook $ ...... | |||
... | |||
myConfig = def { | |||
... | |||
layoutHook = myLayoutHook | |||
... | |||
} | |||
{{Note|1=<nowiki/> | |||
* This extension adds KDE-like screen corners to XMonad. | |||
* By moving your cursor into one of your screen corners you can trigger an X () action, for example XMonad.Actions.GridSelect.goToSelected or XMonad.Actions.CycleWS.nextWS etc.}} | |||
=== Increase the number of workspaces === | === Increase the number of workspaces === | ||
Line 179: | Line 267: | ||
]</nowiki> | ]</nowiki> | ||
}} | }} | ||
=== Checking for duplicate key bindings === | |||
[https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Util-EZConfig.html XMonad.Util.EZConfig] provides a function {{ic|checkKeymap}} to check for duplicate key bindings, otherwise the duplicates will be silently ignored. | |||
{{hc|xmonad.hs| | |||
<nowiki>main = xmonad $ myConfig | |||
myKeymap = [("S-M-c", kill), ...] | |||
myConfig = def { | |||
... | |||
startupHook = do | |||
return () >> checkKeymap myConfig myKeymap | |||
...other operation you defined here... | |||
... | |||
} `additionalKeysP` myKeymap</nowiki>}} | |||
{{Note| | |||
* {{ic|return ()}} in the example above is very important! Otherwise, you might run into problems with infinite mutual recursion. | |||
* {{ic|return ()}} introduces enough laziness to break the deadlock: the definition of myConfig depends on the definition of startupHook, which depends on the definition of myConfig, ..., and so on.}} | |||
=== Making room for docks/panels/trays (Xmobar, Tint2, Conky, etc) === | === Making room for docks/panels/trays (Xmobar, Tint2, Conky, etc) === | ||
Line 197: | Line 304: | ||
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) | ||
=== Adding tags to windows === | |||
with [https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Actions-TagWindows.html XMonad.Actions.TagWindows], users can operate on windows having the same tags. | |||
{{hc|xmonad.hs| | |||
... | |||
import XMonad.Actions.TagWindows | |||
... | |||
<nowiki> | |||
myKeys = | |||
... other key bindings ... | |||
-- Tag | |||
-- , ("M-C-t", withFocused (addTag "abc")) -- add a specific tag "abc" | |||
-- , ("M-C-d", withFocused (delTag "abc")) -- delete the tag "abc" from the focused window | |||
-- , ("M-C-h", withTaggedGlobalP "abc" shiftHere) -- shift windows with tag "abc" here | |||
, ("M-C-a", tagPrompt defaultXPConfig $ withFocused . addTag ) -- prompt for inputs of tag names | |||
, ("M-C-h", tagPrompt defaultXPConfig (`withTaggedGlobalP` shiftHere)) -- shift windows with user defined tags (input) here | |||
, ("M-C-d", tagDelPrompt defaultXPConfig) -- delete a user-defined tag (input) | |||
, ("M-C-t", tagPrompt defaultXPConfig focusUpTaggedGlobal) -- switch between windows in all workspaces with user-defined tags (input) | |||
, ("M-C-f", tagPrompt defaultXPConfig (`withTaggedGlobal` float)) -- float windows with user-defined tags (input) | |||
</nowiki> | |||
}} | |||
=== Equally sized gaps between windows === | === Equally sized gaps between windows === | ||
If your goal is to have equally sized gaps between individual windows and the screen, the following code will not work as expected: | If your goal is to have equally sized gaps between individual windows and the screen, the following code will not work as expected: | ||
layoutHook = spacing 10 $ Tall | layoutHook = spacing 10 $ Tall 1 (3/100) (1/2) ||| Full | ||
This makes each window have its own spacing in each direction. If you have two windows side-by-side, the spacing in the middle will be combined, creating a gap that is twice as large as needed. | This makes each window have its own spacing in each direction. If you have two windows side-by-side, the spacing in the middle will be combined, creating a gap that is twice as large as needed. | ||
Line 207: | Line 336: | ||
A workaround is to specify both a screen and a window spacing, but only use the top and left margins for the screen and bottom and right margins for the windows. To do this, change the above code into: | A workaround is to specify both a screen and a window spacing, but only use the top and left margins for the screen and bottom and right margins for the windows. To do this, change the above code into: | ||
layoutHook = spacingRaw False (Border 10 0 10 0) True (Border 0 10 0 10) True $ Tall | layoutHook = spacingRaw False (Border 10 0 10 0) True (Border 0 10 0 10) True $ Tall 1 (3/100) (1/2) ||| Full | ||
=== Using xmobar with xmonad === | === Using xmobar with xmonad === | ||
Line 214: | Line 343: | ||
'''[[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}} | 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}}, or you can use {{AUR|xmobar-git}}. | ||
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 233: | Line 362: | ||
==== More configurable ==== | ==== More configurable ==== | ||
As of xmonad(-contrib) 0.9, there is a new [https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Hooks-DynamicLog.html#v:statusBar statusBar] function in [ | As of xmonad(-contrib) 0.9, there is a new [https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Hooks-DynamicLog.html#v:statusBar statusBar] function in [https://hackage.haskell.org/package/xmonad-contrib/docs/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 | ||
* The PP that determines what is being written to the bar | * The PP that determines what is being written to the bar | ||
Line 267: | Line 396: | ||
{{hc|~/.xmobarrc|<nowiki> | {{hc|~/.xmobarrc|<nowiki> | ||
Config { ... | Config { ... | ||
, commands = [ Run StdinReader .... ] | , commands = [ Run StdinReader, .... ] | ||
... | ... | ||
, template = " %StdinReader% ... " | , template = " %StdinReader% ... " | ||
Line 276: | Line 405: | ||
=== Controlling xmonad with external scripts === | === Controlling xmonad with external scripts === | ||
Here are a few ways to do it, | Here are a few ways to do it, | ||
* use the following xmonad extension, [ | * use the following xmonad extension, [https://hackage.haskell.org/package/xmonad-contrib/docs/XMonad-Hooks-ServerMode.html XMonad.Hooks.ServerMode]. | ||
* simulate keypress events using {{Pkg|xdotool}} or similar programs. See this [ | * simulate keypress events using {{Pkg|xdotool}} or similar programs. See this [https://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 318: | Line 448: | ||
</nowiki>}} | </nowiki>}} | ||
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 [ | 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 [https://wiki.haskell.org/Xmonad/Config_archive/adamvo%27s_xmonad.hs Adamvo's xmonad.hs] | ||
=== KDE and xmonad === | === KDE and xmonad === | ||
Line 343: | Line 473: | ||
=== IM Layout for Skype === | === IM Layout for Skype === | ||
In | In order to create an IM layout for the newer versions of skype, the following code can be used: | ||
{{hc|xmonad.hs|<nowiki> | {{hc|xmonad.hs|<nowiki> | ||
myIMLayout = withIM (1%7) skype Grid | myIMLayout = withIM (1%7) skype Grid | ||
Line 354: | Line 484: | ||
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] [ | * brisbin33 :: simple, useful, readable :: [https://github.com/pbrisbin/xmonad-config config] [https://files.pbrisbin.com/screenshots/current_desktop.png screenshot] | ||
* jelly :: Configuration with prompt, different layouts, twinview with xmobar :: [https://github.com/jelly/dotfiles/tree/master/.xmonad/xmonad.hs xmonad.hs] | * jelly :: Configuration with prompt, different layouts, twinview with xmobar :: [https://github.com/jelly/dotfiles/tree/master/.xmonad/xmonad.hs xmonad.hs] | ||
* MrElendig :: Simple configuration, with xmobar :: [https://github.com/MrElendig/dotfiles-alice/blob/master/.xmonad/xmonad.hs xmonad.hs], [https://github.com/MrElendig/dotfiles-alice/blob/master/.xmobarrc .xmobarrc], [ | * MrElendig :: Simple configuration, with xmobar :: [https://github.com/MrElendig/dotfiles-alice/blob/master/.xmonad/xmonad.hs xmonad.hs], [https://github.com/MrElendig/dotfiles-alice/blob/master/.xmobarrc .xmobarrc], [https://arch.har-ikkje.net/gfx/ss/2010-09-05-163305_2960x1050_scrot.png screenshot]. | ||
* thayer :: A minimal mouse-friendly config ideal for netbooks :: [ | * thayer :: A minimal mouse-friendly config ideal for netbooks :: [https://wiki.haskell.org/Xmonad/Config_archive/Thayer_Williams%27_xmonad.hs configs] [https://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 [ | * vogt :: Check out adamvo's config and many others in the official [https://wiki.haskell.org/Xmonad/Config_archive Xmonad/Config archive] | ||
* wulax :: Example of using xmonad inside Xfce | * wulax :: Example of using xmonad inside Xfce. :: [https://gist.github.com/jsjolund/94f6821b248ff79586ba xmonad.hs], [https://i.imgur.com/at9AbOl.png screenshot]. | ||
* alex-courtis :: Clean xmonad, xmobar, media keys, screenshot, j4/dmenu; fonts rendered at the DPI reported by the monitor :: [https://github.com/alex-courtis/arch/blob/ | * alex-courtis :: Clean xmonad, xmobar, media keys, screenshot, j4/dmenu; fonts rendered at the DPI reported by the monitor :: [https://github.com/alex-courtis/arch/blob/ea77edca1a1cd92e87d9c403dae891d03b9ee94e/home/.xmonad/xmonad.hs xmonad.hs], [https://raw.githubusercontent.com/alex-courtis/arch/9e3f16b93f89c328b57a96600da7fd39b81bae8e/ss.png screenshot]. | ||
* TobbeBob123 :: Config for TobbeBob123 where you can see all the keybinding with a simple keybinding ({{ic|Mod4+s}}). If you want a whole and complete Xmonad with theme and everything you see in the picture linked. You can run the script called TobbeOS. :: [https://gitlab.com/TobbeBob123/TobbeOS.git TobbeOS]. [https://gitlab.com/TobbeBob123/Xmonad.git Xmonad repository], [https://gitlab.com/TobbeBob123/TobbeOS/-/raw/master/TobbeOSPNG/TobbeOS_Screenshot.png Screenshot]. | |||
* AzureOrange :: Split configuration for xmonad built with stack (gaps, layouts, scratchpads, window management and window swallowing etc.) with xmobar, trayer and dmenu. :: [https://gitlab.com/azureorangexyz/dotfiles/-/tree/main xmonad.hs] [https://gitlab.com/azureorangexyz/dotfiles/-/blob/main/.local/source/xmonad/screenshots/xmonad_archwiki.png screenshot] | |||
== Troubleshooting == | == Troubleshooting == | ||
=== Xfce 4 and xmonad === | === Xfce 4 and xmonad === | ||
Line 451: | Line 511: | ||
Also add an entry to ''Settings > Session and Startup > Application Autostart'' that runs {{ic|xmonad --replace}}. | Also add an entry to ''Settings > Session and Startup > Application Autostart'' that runs {{ic|xmonad --replace}}. | ||
=== Missing xmonad- | === Missing xmonad-x86_64-linux === | ||
xmonad should automatically create the {{ic|xmonad-X86_64-linux}} file (in {{ic|~/.xmonad/}}). If this it not the case, grab a configuration file from the [https://wiki.haskell.org/Xmonad/Config_archive xmonad wiki] or create your [https://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 directory: | |||
$ xmonad --recompile | |||
xmonad --recompile | |||
Now you should see the file. | Now you should see the file. | ||
Line 461: | Line 522: | ||
=== Problems with Java applications === | === Problems with Java applications === | ||
If you have problems, like Java application Windows not resizing, or menus immediately closing after you click, see [[Java#Gray window, applications not resizing with WM, menus immediately closing]]. | If you have problems, like Java application Windows not resizing, or menus immediately closing after you click, see [[Java#Gray window, applications not resizing with WM, menus immediately closing]]. | ||
=== 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. | ||
You can also configure xmonad to respect size hints, but this will leave a gap instead. See [https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Layout-LayoutHints.html the documentation on Xmonad.Layout.LayoutHints]. | |||
=== Chromium/Chrome will not go fullscreen === | |||
If Chrome fails to go fullscreen when {{ic|F11}} is pressed, you can use the [https://hackage.haskell.org/package/xmonad-contrib/docs/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 [ | |||
import XMonad.Hooks.EwmhDesktops | import XMonad.Hooks.EwmhDesktops | ||
and then add {{ic| | and then add {{ic|ewmhFullscreen . ewmh}} to the appropriate place; for example: | ||
{{bc|<nowiki> | {{bc|<nowiki> | ||
... | ... | ||
xmonad $ def | main = xmonad $ ewmhFullscreen . ewmh $ def | ||
... | ... | ||
</nowiki>}} | </nowiki>}} | ||
Line 488: | Line 547: | ||
=== Multitouch / touchegg === | === Multitouch / touchegg === | ||
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 [ | 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 [https://hackage.haskell.org/package/xmonad-contrib/docs/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 [ | Users with a keyboard with azerty layout can run into issues with certain keybindings. Using the [https://hackage.haskell.org/package/xmonad-contrib/docs/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 === | ||
Line 498: | Line 557: | ||
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 {{ic|Super+p}}. | ||
=== Chrome/Chromium not displaying defined window border color === | |||
Chromium and Chrome browser windows will not have the defined border color per default but a blurred transparent one. This problem is known for a long [https://xmonad.haskell.narkive.com/3NiS9dFl/transparent-border-with-chrome-beta-unstable time] but easy to fix. | |||
Activating `Use system title bar and borders` in the browser options should fix it immediately. | |||
=== Problems with focused border in VirtualBox === | === Problems with focused border in VirtualBox === | ||
Line 506: | Line 570: | ||
=== 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 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 [ | 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 [https://steamcommunity.com/app/221410/discussions/0/864960353968561426/]: | ||
-windowed | -windowed | ||
Line 514: | Line 578: | ||
className =? "hl_linux" --> doFloat | className =? "hl_linux" --> doFloat | ||
This can also be worked around by making xmonad pay attention to EWMH hints and including its fullscreen hook [ | This can also be worked around by making xmonad pay attention to EWMH hints and including its fullscreen hook [https://hackage.haskell.org/package/xmonad-contrib/docs/XMonad-Hooks-EwmhDesktops.html]: | ||
main = xmonad $ ewmh def{ handleEventHook = | main = xmonad $ ewmh def{ handleEventHook = | ||
handleEventHook def <+> fullscreenEventHook } | handleEventHook def <+> fullscreenEventHook } | ||
This has a few other effects and makes it behave more akin to fullscreen | This has a few other effects and makes it behave more akin to fullscreen applications in other WMs. | ||
=== LibreOffice - focus flicking between main window and dialog === | === 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 | 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]] {{ic|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. | to use the general (QT) UI. | ||
=== IntelliJ IDEA and xmonad === | |||
==== Dialog windows ==== | |||
[[IntelliJ IDEA]] has received better support for tiling window managers. But there are still some annoying issues, some of them have simple solutions: | |||
* The ''Find In Files'' dialog window closes immediately if mouse pointer moves out of the dialog window boundaries. This only happens with the ''Find In Files'' dialog window, and is not reproducible with the ''Navigate to…'' dialog. The ''Find In Files'' behavior is expected, assuming the default "focus follows mouse" logic of ''xmonad''. The ''Find In Files'' window closes when it loses focus on all systems. | |||
:'''Solution''': You can change it by "pinning" the popup — there is a corresponding button in top right corner [https://youtrack.jetbrains.com/issue/IDEA-65637#focus=Comments-27-5142464.0-0]. | |||
* When viewing changed files between Git commits (using the ''Changes Between aaaa and local version bbbb'' dialog), the window with file-level diffs opens behind the dialog window. | |||
:'''Solution''': Unknown | |||
=== Problems with finding shared libraries after update === | === Problems with finding shared libraries after update === | ||
Line 533: | Line 608: | ||
The xmonad executable is located in {{ic|~/.xmonad/}}. After upgrading xmonad, an old executable might persist and need in that case be removed for xmonad to compile a new executable. Alternatively use {{ic|xmonad --recompile}}. | The xmonad executable is located in {{ic|~/.xmonad/}}. After upgrading xmonad, an old executable might persist and need in that case be removed for xmonad to compile a new executable. Alternatively use {{ic|xmonad --recompile}}. | ||
In the case that {{ic|xmonad --recompile}} | The recompilation can be automated by adding a pacman hook like the following to {{ic|/etc/pacman.d/hooks/xmonad.hook}} (you may have to first create the {{ic|hooks}} directory): | ||
[Trigger] | |||
Operation = Upgrade | |||
Type = Package | |||
Target = xmonad | |||
[Action] | |||
Description = Recompiling xmonad... | |||
When = PostTransaction | |||
Exec = /usr/bin/sudo -u YOUR_USERNAME /usr/bin/xmonad --recompile | |||
Where {{ic|YOUR_USERNAME}} is the username that you run xmonad from. | |||
In the case that {{ic|xmonad --recompile}} cannot find any modules at all (including {{ic|XMonad}} itself), try regenerating the package database cache: | |||
# ghc-pkg recache | |||
=== Broken/missing XMonad.Prompt and window decorations === | === Broken/missing XMonad.Prompt and window decorations === | ||
XMonad by default uses the font {{ic|-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*}} [https://wiki.haskell.org/Xmonad/Frequently_asked_questions#Tabbed_or_other_decorated_layouts_not_shown]. | XMonad by default uses the font {{ic|-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*}} [https://wiki.haskell.org/Xmonad/Frequently_asked_questions#Tabbed_or_other_decorated_layouts_not_shown]. | ||
If this font is missing those windows simply fail to render at all. Easiest fix is to install {{ | If this font is missing those windows simply fail to render at all. Easiest fix is to install {{Pkg|xorg-fonts-misc}}. | ||
== See also == | == See also == | ||
*[ | *[https://xmonad.org/ xmonad] - The official xmonad website | ||
*[https://wiki.haskell.org/Xmonad/Config_archive/Template_xmonad.hs xmonad.hs] - Template xmonad.hs | *[https://wiki.haskell.org/Xmonad/Config_archive/Template_xmonad.hs xmonad.hs] - Template xmonad.hs | ||
*[ | *[https://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 | ||
Line 552: | Line 641: | ||
*[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] | ||
*[https://github.com/alexkay/xmonad-log-applet xmonad-log-applet] - An applet for the GNOME, MATE or | *[https://github.com/alexkay/xmonad-log-applet xmonad-log-applet] - An applet for the GNOME, MATE or Xfce panel. |
Latest revision as of 07:34, 1 May 2024
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.
Installation
Install the xmonad package which provides a very basic configuration, ideally also install xmonad-contrib for most notably a more useful desktop configuration as well as additional tiling algorithms, configurations, scripts, etc.
Alternatively, install xmonad-gitAUR, the development version, with some additional dependencies; and likewise xmonad-contrib-gitAUR.
xmonad --recompile
after you upgrade xmonad, otherwise it might have problems finding shared libraries the next time you start it. To automate this process, see #Problems with finding shared libraries after update.Starting
Run xmonad
with xinit.
Alternatively, select Xmonad from the session menu in a display manager of choice.
Make sure you have the Xterm package installed or have changed the terminal emulator in the configuration. Otherwise you will not be able to do anything in xmonad.
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.
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 def function.
This is achieved by writing an xmonad.hs
like this:
import XMonad main = xmonad def { 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 def).
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 $ def { 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 also helps with problems in some modern programs like Chromium.
It can be added like so:
import XMonad import XMonad.Config.Desktop main = xmonad desktopConfig { terminal = "urxvt" , modMask = mod4Mask }
Exiting xmonad
To end the current xmonad session, press Mod+Shift+Q
. By default, Mod
is the Alt
key.
To confirm exit each time,
xmonad.hs
... import XMonad.Prompt.ConfirmPrompt ... myKeys :: [(String, X ())] myKeys = ... ("M-S-q", confirmPrompt defaultXPConfig "exit" $ io exitSuccess) ...
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
import XMonad.Util.Paste -- Remember to include this line -- X-selection-paste buffer , ((0, xK_Insert), pasteSelection)
Pressing the Insert
key will now paste the mouse buffer in the active window.
- Note that
pasteSelection
usesgetSelection
fromXMonad.Util.XSelection
and so is heir to its flaws. getSelection
"is fundamentally implemented incorrectly and may, among other possible failure modes, deadlock or crash". For details, see [1].- These errors are generally very rare in practice, but still exist.
Keyboard shortcuts
Default keyboard shortcuts are listed xmonad(1).
Targeting unbound keys
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 into list of keybindings in your xmonad.hs
:
((0, 0x1008FF2A), spawn "sudo systemctl suspend")
You can also search for the Xf86 key name in Graphics.X11.ExtraTypes.XF86 module, and use its KeySym
constant (such as xF86XK_PowerDown
) instead of a keycode as shown in the previous example. You will also need to import the module in your xmonad.hs
for the key constant to be available. See more elaborate example with multiple keys in format used by additionalKeys
function:
import Graphics.X11.ExtraTypes.XF86 ... myKeys = [ ((0, xF86XK_PowerDown), spawn "sudo systemctl suspend") , ((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 10%+") , ((0, xF86XK_AudioLowerVolume), spawn "amixer -D pulse sset Master 10%-") , ((0, xF86XK_AudioMute), spawn "amixer -D pulse sset Master toggle") , ((0, xF86XK_MonBrightnessUp), spawn "brightnessctl set +10%") , ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 10%-") ... ]
Run X () actions by touching the edge of your screen with your mouse
With XMonad.Hooks.ScreenCorners, users can have KDE-like screen corners with XMonad.
Switch workspaces with ScreenCorners (KDE-like)
Define a series of operations in startupHook:
xmonad.hs
... import XMonad.Hooks.ScreenCorners ... mystartupHook = do ... ... example ... addScreenCorners [ (SCLowerLeft, prevWS) , (SCLowerRight, nextWS) , (SCUpperLeft, spawnSelected' myAppGrid) , (SCUpperRight, goToSelected $ mygridConfig' myColorizer) ] ...
Then add screenCornerEventHook to handleEventHook:
myConfig = def { ... handleEventHook = ... <+> screenCornerEventHook <+> ... ... }
Finally add screenCornerLayoutHook:
... myLayoutHook = screenCornerLayoutHook $ ...... ... myConfig = def { ... layoutHook = myLayoutHook ... }
- This extension adds KDE-like screen corners to XMonad.
- By moving your cursor into one of your screen corners you can trigger an X () action, for example XMonad.Actions.GridSelect.goToSelected or XMonad.Actions.CycleWS.nextWS etc.
Increase the number of workspaces
By default, xmonad uses a set of 9 workspaces. You can change this by changing the workspaces parameter:
xmonad.hs
import XMonad import XMonad.Util.EZConfig (additionalKeys) main=do xmonad $ def { ... , 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 ]
Checking for duplicate key bindings
XMonad.Util.EZConfig provides a function checkKeymap
to check for duplicate key bindings, otherwise the duplicates will be silently ignored.
xmonad.hs
main = xmonad $ myConfig myKeymap = [("S-M-c", kill), ...] myConfig = def { ... startupHook = do return () >> checkKeymap myConfig myKeymap ...other operation you defined here... ... } `additionalKeysP` myKeymap
return ()
in the example above is very important! Otherwise, you might run into problems with infinite mutual recursion.return ()
introduces enough laziness to break the deadlock: the definition of myConfig depends on the definition of startupHook, which depends on the definition of myConfig, ..., and so on.
Making room for docks/panels/trays (Xmobar, Tint2, Conky, etc)
Wrap your layouts with avoidStruts from XMonad.Hooks.ManageDocks for automatic dock/panel/trayer spacing:
import XMonad import XMonad.Hooks.ManageDocks main=do xmonad $ docks def { ... , layoutHook=avoidStruts $ layoutHook def , manageHook=manageHook def <+> manageDocks , ... }
If you ever want to toggle the gaps, this action can be added to your key bindings:
,((modMask x, xK_b ), sendMessage ToggleStruts)
Adding tags to windows
with XMonad.Actions.TagWindows, users can operate on windows having the same tags.
xmonad.hs
... import XMonad.Actions.TagWindows ... myKeys = ... other key bindings ... -- Tag -- , ("M-C-t", withFocused (addTag "abc")) -- add a specific tag "abc" -- , ("M-C-d", withFocused (delTag "abc")) -- delete the tag "abc" from the focused window -- , ("M-C-h", withTaggedGlobalP "abc" shiftHere) -- shift windows with tag "abc" here , ("M-C-a", tagPrompt defaultXPConfig $ withFocused . addTag ) -- prompt for inputs of tag names , ("M-C-h", tagPrompt defaultXPConfig (`withTaggedGlobalP` shiftHere)) -- shift windows with user defined tags (input) here , ("M-C-d", tagDelPrompt defaultXPConfig) -- delete a user-defined tag (input) , ("M-C-t", tagPrompt defaultXPConfig focusUpTaggedGlobal) -- switch between windows in all workspaces with user-defined tags (input) , ("M-C-f", tagPrompt defaultXPConfig (`withTaggedGlobal` float)) -- float windows with user-defined tags (input)
Equally sized gaps between windows
If your goal is to have equally sized gaps between individual windows and the screen, the following code will not work as expected:
layoutHook = spacing 10 $ Tall 1 (3/100) (1/2) ||| Full
This makes each window have its own spacing in each direction. If you have two windows side-by-side, the spacing in the middle will be combined, creating a gap that is twice as large as needed.
A workaround is to specify both a screen and a window spacing, but only use the top and left margins for the screen and bottom and right margins for the windows. To do this, change the above code into:
layoutHook = spacingRaw False (Border 10 0 10 0) True (Border 0 10 0 10) True $ Tall 1 (3/100) (1/2) ||| Full
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, or you can use xmobar-gitAUR.
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
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 def { 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 = def { 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,
- use the following xmonad extension, XMonad.Hooks.ServerMode.
- 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 $ def { --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.
Disable plasmashell
You might want to disable plasmashell (the KDE5 thing responsible for desktop background, taskbar, tray, etc.).
cp /etc/xdg/autostart/plasmashell.desktop ~/.config/autostart/
Then edit ~/.config/autostart/plasmashell.desktop
and replace Exec=plasmashell
with Exec=
. The result will look like this:
~/.config/autostart/plasmashell.desktop
[Desktop Entry] Exec= Name=Plasma Desktop Workspace ... # more stuff
IM Layout for Skype
In order 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. :: xmonad.hs, screenshot.
- alex-courtis :: Clean xmonad, xmobar, media keys, screenshot, j4/dmenu; fonts rendered at the DPI reported by the monitor :: xmonad.hs, screenshot.
- TobbeBob123 :: Config for TobbeBob123 where you can see all the keybinding with a simple keybinding (
Mod4+s
). If you want a whole and complete Xmonad with theme and everything you see in the picture linked. You can run the script called TobbeOS. :: TobbeOS. Xmonad repository, Screenshot. - AzureOrange :: Split configuration for xmonad built with stack (gaps, layouts, scratchpads, window management and window swallowing etc.) with xmobar, trayer and dmenu. :: xmonad.hs screenshot
Troubleshooting
Xfce 4 and xmonad
Use xfceConfig
instead of def
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-x86_64-linux
xmonad should automatically create the xmonad-X86_64-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 directory:
$ xmonad --recompile
Now you should see the file.
Problems with Java applications
If you have problems, like Java application Windows not resizing, or menus immediately closing after you click, see Java#Gray window, 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.
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 ewmhFullscreen . ewmh
to the appropriate place; for example:
... main = xmonad $ ewmhFullscreen . ewmh $ def ...
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.
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
.
Chrome/Chromium not displaying defined window border color
Chromium and Chrome browser windows will not have the defined border color per default but a blurred transparent one. This problem is known for a long time but easy to fix. Activating `Use system title bar and borders` in the browser options should fix it immediately.
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 [3]:
-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 [4]:
main = xmonad $ ewmh def{ handleEventHook = handleEventHook def <+> fullscreenEventHook }
This has a few other effects and makes it behave more akin to fullscreen applications 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.
IntelliJ IDEA and xmonad
Dialog windows
IntelliJ IDEA has received better support for tiling window managers. But there are still some annoying issues, some of them have simple solutions:
- The Find In Files dialog window closes immediately if mouse pointer moves out of the dialog window boundaries. This only happens with the Find In Files dialog window, and is not reproducible with the Navigate to… dialog. The Find In Files behavior is expected, assuming the default "focus follows mouse" logic of xmonad. The Find In Files window closes when it loses focus on all systems.
- Solution: You can change it by "pinning" the popup — there is a corresponding button in top right corner [5].
- When viewing changed files between Git commits (using the Changes Between aaaa and local version bbbb dialog), the window with file-level diffs opens behind the dialog window.
- Solution: Unknown
The xmonad executable is located in ~/.xmonad/
. After upgrading xmonad, an old executable might persist and need in that case be removed for xmonad to compile a new executable. Alternatively use xmonad --recompile
.
The recompilation can be automated by adding a pacman hook like the following to /etc/pacman.d/hooks/xmonad.hook
(you may have to first create the hooks
directory):
[Trigger] Operation = Upgrade Type = Package Target = xmonad [Action] Description = Recompiling xmonad... When = PostTransaction Exec = /usr/bin/sudo -u YOUR_USERNAME /usr/bin/xmonad --recompile
Where YOUR_USERNAME
is the username that you run xmonad from.
In the case that xmonad --recompile
cannot find any modules at all (including XMonad
itself), try regenerating the package database cache:
# ghc-pkg recache
Broken/missing XMonad.Prompt and window decorations
XMonad by default uses the font -misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*
[6].
If this font is missing those windows simply fail to render at all. Easiest fix is to install xorg-fonts-misc.
See also
- xmonad - The official xmonad website
- xmonad.hs - Template xmonad.hs
- xmonad: a guided tour
- dzen - General purpose messaging and notification program
- 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
- Share your xmonad desktop!
- xmonad hacking thread
- xmonad-log-applet - An applet for the GNOME, MATE or Xfce panel.