https://wiki.archlinux.org/api.php?action=feedcontributions&user=Ronpaul&feedformat=atom
ArchWiki - User contributions [en]
2024-03-29T05:03:22Z
User contributions
MediaWiki 1.41.0
https://wiki.archlinux.org/index.php?title=Xmonad&diff=171062
Xmonad
2011-11-25T07:50:05Z
<p>Ronpaul: touchegg with xmonad</p>
<hr />
<div>[[Category:X Server (English)]]<br />
[[Category:Tiling WMs (English)]]<br />
[[fr:Xmonad]]<br />
{{i18n|Xmonad}}<br />
<br />
[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.<br />
<br />
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.<br />
<br />
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.<br />
<br />
For more information, please visit the xmonad website: http://xmonad.org/<br />
<br />
==Installation==<br />
<br />
{{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.<br />
<br />
===Development version (xmonad-darcs)===<br />
<br />
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:<br />
<br />
* {{AUR|xmonad-darcs}} -- The core window manager<br />
* {{AUR|xmonad-contrib-darcs}} -- Contributed extensions providing custom layouts, configurations, etc.<br />
<br />
==Configuration==<br />
<br />
===Starting xmonad===<br />
To start xmonad automatically, simply add the command {{Codeline|xmonad}} to your startup script (e.g. {{Filename|~/.xinitrc}}). GDM and KDM users can create a new session file and then select xmonad from the appropriate Session menu.<br />
<br />
{{Note|Recently, users in #xmonad have stated that {{Codeline|exec}} is not required before {{Codeline|xmonad}}; simply adding {{Codeline|xmonad}} as the last line in your startup script is the proper way to start this WM. Please use whichever method works for you. If using {{Codeline|ck-launch-session}}, the {{Codeline|exec}} is probably still required.}}<br />
<br />
{{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. {{Filename|~/.xinitrc}}):<br><br />
{{Cli|xsetroot -cursor_name left_ptr}}}}<br />
<br />
Also, xmonad defaults to the U.S. keyboard layout, so if you want, for example, the German keyboard layout, add the following to {{Filename|~/.xinitrc}} or read more about setting keyboard layouts [[Xorg#Keyboard_settings|here]]:<br />
setxkbmap -layout de<br />
<br />
Example {{Filename|~/.xinitrc}}:<br />
# set the cursor<br />
xsetroot -cursor_name left_ptr<br />
# set German keyboard layout<br />
setxkbmap -layout de<br />
# start xmonad<br />
exec ck-launch-session xmonad<br />
<br />
If, for some reason, xmonad does not start, check if you have an {{Filename|.xmonad}} directory in your home directory. If not, create it:<br />
mkdir ~/.xmonad<br />
<br />
===Configuring xmonad===<br />
<br />
xmonad users can modify, override or extend the default settings with the {{Filename|~/.xmonad/xmonad.hs}} configuration file. Recompiling is done on the fly, with the Mod+q shortcut.<br />
<br />
If you find you do not have a directory at {{Filename|~/.xmonad}}, run {{Codeline|xmonad --recompile}} to create it.<br />
<br />
The "default config" for xmonad is quite usable and it is achieved by simply running without an {{Filename|xmonad.hs}} entirely. Therefore, even after you run {{Codeline|xmonad --recompile}} you will most likely not have an {{Filename|~/.xmonad/xmonad.hs}} file. If you would like to start tweaking things, simply create the file and edit it as described below.<br />
<br />
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:<br />
<br />
* [http://haskell.org/haskellwiki/Xmonad xmonad wiki]<br />
* [http://haskell.org/haskellwiki/Xmonad/Config_archive xmonad config archive]<br />
* [http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions xmonad FAQ]<br />
* Arch Linux [http://bbs.archlinux.org/viewtopic.php?id=40636 forum thread]<br />
<br />
The best approach is to only place your changes and customizations in {{Filename|~/.xmonad/xmonad.hs}} and write it such that any unset parameters are picked up from the built-in defaultConfig.<br />
<br />
This is achieved by writing an {{Filename|xmonad.hs}} like this:<br />
<br />
import XMonad<br />
<br />
main = do<br />
xmonad $ defaultConfig<br />
{ terminal = "urxvt"<br />
, modMask = mod4Mask<br />
, borderWidth = 3<br />
}<br />
<br />
This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the function defaultConfig).<br />
<br />
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 {{Filename|~/.xmonad/xmonad.hs}}. This makes large customizations like your layout and manage hooks easier to visualize and maintain.<br />
<br />
The simple {{Filename|xmonad.hs}} from above could have been written like this:<br />
<br />
import XMonad<br />
<br />
main = do<br />
xmonad $ defaultConfig<br />
{ terminal = myTerminal<br />
, modMask = myModMask<br />
, borderWidth = myBorderWidth<br />
}<br />
<br />
-- yes, these are functions; just very simple ones<br />
-- that accept no input and return static values<br />
myTerminal = "urxvt"<br />
myModMask = mod4Mask -- Win key or Super_L<br />
myBorderWidth = 3<br />
<br />
Also, order at top level (main, myTerminal, myModMask etc.), or within the {} does not matter in Haskell, as long as imports come first.<br />
<br />
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.<br />
<br />
{<br />
terminal = myTerminal,<br />
focusFollowsMouse = myFocusFollowsMouse,<br />
borderWidth = myBorderWidth,<br />
modMask = myModMask,<br />
-- numlockMask deprecated in 0.9.1<br />
-- numlockMask = myNumlockMask,<br />
workspaces = myWorkspaces,<br />
normalBorderColor = myNormalBorderColor,<br />
focusedBorderColor = myFocusedBorderColor,<br />
<br />
-- key bindings<br />
keys = myKeys,<br />
mouseBindings = myMouseBindings,<br />
<br />
-- hooks, layouts<br />
layoutHook = myLayout,<br />
manageHook = myManageHook,<br />
handleEventHook = myEventHook,<br />
logHook = myLogHook,<br />
startupHook = myStartupHook<br />
}<br />
<br />
===Exiting xmonad===<br />
To end the current xmonad session, press {{ic|Mod + Shift + Q}}. By default, {{ic|Mod}} is the {{ic|Alt}} key.<br />
<br />
==Tips and tricks==<br />
===Complementary applications===<br />
There are number of complementary utilities that work well with xmonad. The most common of these include:<br />
<br />
* [[dmenu]]<br />
* [[xmobar]]<br />
* [[dzen]]<br />
* [[Conky]] and {{Package AUR|conky-cli}}<br />
* [[gmrun]]<br />
* [[Unclutter]] - a small utility to hide the mouse pointer<br />
* [http://uhsure.com/xmonad-log-applet.html XMonad-log-applet] - a GNOME applet for the gnome-panel (the package is in the [[Official Repositories]])<br />
<br />
===Making room for conky or tray apps===<br />
Wrap your layouts with avoidStruts from XMonad.Hooks.ManageDocks for automatic dock/panel/trayer spacing:<br />
<br />
import XMonad<br />
import XMonad.Hooks.ManageDocks<br />
<br />
main=do<br />
xmonad $ defaultConfig<br />
{ ...<br />
, layoutHook=avoidStruts $ layoutHook defaultConfig<br />
, manageHook=manageHook defaultConfig <+> manageDocks<br />
, ...<br />
}<br />
<br />
If you ever want to toggle the gaps, this action can be added to your key bindings:<br />
,((modMask x, xK_b ), sendMessage ToggleStruts)<br />
<br />
===Using xmobar with xmonad===<br />
'''[[xmobar]]''' is a light and minimalistic text-based bar, designed to work with xmonad.<br />
To use xmobar with xmonad, you will need two packages in addition to the {{Package Official|xmonad}} package. These packages are {{Package Official|xmonad-contrib}} and {{Package Official|xmobar}} from the [[Official Repositories]], or you can use {{Package AUR|xmobar-git}} from the [[AUR]] instead of the official xmobar.<br />
<br />
Here we will start xmobar from within xmonad, which reloads xmobar whenever you reload xmonad.<br />
<br />
Open {{Filename|~/.xmonad/xmonad.hs}} in your favorite editor, and choose one of the two following options:<br />
<br />
====Option 1: Quick, less flexible====<br />
{{Note|There is also {{Pkg|dzen2}} which you can substitute for {{Pkg|xmobar}} in either case.}}<br />
<br />
Common imports:<br />
<br />
import XMonad<br />
import XMonad.Hooks.DynamicLog<br />
<br />
The xmobar action starts xmobar and returns a modified config that includes all the options described in the [[xmonad#Option 2: More configurable|xmonad:Option2: More configurable]] choice.<br />
<br />
main = xmonad =<< xmobar defaultConfig { modMask = mod4Mask {- or any other configurations here ... -}}<br />
<br />
==== Option 2: More Configurable ====<br />
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:<br />
* The command used to execute the bar<br />
* The PP that determines what is being written to the bar<br />
* The keybinding to toggle the gap for the bar<br />
<br />
Following is an example of how to use it:<br />
{{File|name=~/.xmonad/xmonad.hs|content=<nowiki>-- Imports.<br />
import XMonad<br />
import XMonad.Hooks.DynamicLog<br />
<br />
-- The main function.<br />
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig<br />
<br />
-- Command to launch the bar.<br />
myBar = "xmobar"<br />
<br />
-- Custom PP, configure it as you like. It determines what's being written to the bar.<br />
myPP = xmobarPP { ppCurrent = xmobarColor "#429942" "" . wrap "<" ">" }<br />
<br />
-- Keybinding to toggle the gap for the bar.<br />
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)<br />
<br />
-- Main configuration, override the defaults to your liking.<br />
myConfig = defaultConfig { modMask = mod4Mask }<br />
</nowiki>}}<br />
<br />
==== Verify XMobar Config ====<br />
The template and default xmobarrc contains this.<br />
<br />
At last, open up {{Filename|~/.xmobarrc}} and make sure you have StdinReader in the template and run the plugin. E.g.<br />
{{File|name=~/.xmobarrc|content=<br />
<nowiki><br />
Config { ...<br />
, commands = [ Run StdinReader .... ]<br />
...<br />
, template = " %StdinReader% ... "<br />
}<br />
</nowiki><br />
}}<br />
Now, all you should have to do is either to start, or restart, xmonad.<br />
<br />
===Controlling xmonad with external scripts===<br />
There are at least two ways to do this.<br />
<br />
Firstly, you can use the following xmonad extension, [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ServerMode.html XMonad.Hooks.ServerMode].<br />
<br />
Secondly, you can simulate keypress events using {{Pkg|xdotool}} or similar programs. See this [http://ubuntuforums.org/archive/index.php/t-658040.html Ubuntu forums thread]. The following command would simulate the keypress {{ic|Super + N}}:<br />
xdotool key Super+n<br />
<br />
===Launching another window manager within xmonad===<br />
If you are using {{Package 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 {{Filename|~/.xmonad/xmonad.hs}}. Here is the script.<br />
<br />
{{File|name=~/bin/obtoxmd|content=<br />
<nowiki><br />
#!/bin/sh<br />
openbox<br />
xmonad<br />
</nowiki><br />
}}<br />
<br />
And here are the modifications you need to add to your {{Filename|~/.xmonad/xmonad.hs}}:<br />
<br />
{{File|name=~/.xmonad/xmonad.hs|content=<br />
<nowiki><br />
import XMonad<br />
--You need to add this import<br />
import XMonad.Util.Replace<br />
<br />
main do<br />
-- And this "replace"<br />
replace<br />
xmonad $ defaultConfig<br />
{<br />
--Add the usual here<br />
}<br />
<br />
</nowiki><br />
}}<br />
<br />
You also need to add the following keybinding<br />
<br />
{{File|name=~/xmonad/xmonad.hs|content=<br />
<nowiki><br />
--Add a keybinding as follows:<br />
((modm .|. shiftMask, xK_o ), restart "/home/abijr/bin/obtoxmd" True)<br />
</nowiki><br />
}}<br />
<br />
Just remember to add a comma before or after and change the path to your actual script path. Now just {{Keypress|Mod}}+{{Keypress|Q}} (restart xmonad to refresh the config), and than hit {{Keypress|Mod}}+{{Keypress|Shift}}+{{Keypress|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 {{Filename|~/.xmonad/xmonad.hs}} which uses this setup [http://www.haskell.org/haskellwiki/Xmonad/Config_archive/adamvo%27s_xmonad.hs Adamvo's xmonad.hs]<br />
<br />
===Example configurations===<br />
Below are some example configurations from fellow xmonad users. Feel free to add links to your own.<br />
* brisbin33 :: complex and simpler branches, importable dzen and scratchpad modules, very readable :: [https://github.com/pbrisbin/xmonad-config config] [http://pbrisbin.com/static/screenshots/current_desktop.png screenshot]<br />
* jelly :: Configuration with prompt, different layouts, twinview with xmobar :: [http://github.com/jelly/dotfiles/tree/master/.xmonad/xmonad.hs xmonad.hs]<br />
* 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].<br />
* 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]<br />
* 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].<br />
* vogt :: Check out adamvo's config and many others in the official [http://haskell.org/haskellwiki/Xmonad/Config_archive Xmonad/Config archive]<br />
<br />
==Troubleshooting==<br />
===GNOME 3 and xmonad===<br />
With the release of GNOME 3, some additional steps are necessary to make GNOME play nicely with xmonad.<br />
<br />
First, add an xmonad session file for use by gnome-session ({{Filename|/usr/share/gnome-session/sessions/xmonad.session}}):<br />
<br />
<pre><br />
[GNOME Session]<br />
Name=Xmonad session<br />
RequiredComponents=gnome-panel;gnome-settings-daemon;<br />
RequiredProviders=windowmanager;notifications;<br />
DefaultProvider-windowmanager=xmonad<br />
DefaultProvider-notifications=notification-daemon<br />
</pre><br />
Now create a desktop file for GDM ({{Filename|/usr/share/xsessions/xmonad-gnome-session.desktop}}):<br />
<pre><br />
[Desktop Entry]<br />
Name=Xmonad GNOME<br />
Comment=Tiling window manager<br />
TryExec=/usr/bin/gnome-session<br />
Exec=gnome-session --session=xmonad<br />
Type=XSession<br />
</pre><br />
Xmonad should now appear in the list of GDM sessions and also play nicely with gnome-session itself.<br />
<br />
===GDM 2.x/KDM cannot find xmonad===<br />
You can force GDM to launch xmonad by creating the file {{Filename|xmonad.desktop}} in the {{Filename|/usr/share/xsessions}} directory and add the contents:<br />
<br />
[Desktop Entry]<br />
Encoding=UTF-8<br />
Name=xmonad<br />
Comment=This session starts xmonad<br />
Exec=/usr/bin/xmonad<br />
Type=Application<br />
<br />
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.<br />
<br />
For KDM, you will need to create the file here as {{Filename|/usr/share/apps/kdm/sessions/xmonad.desktop}}<br />
<br />
Official documentation can be found here:<br />
[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]<br />
<br />
===Missing xmonad-i386-linux or xmonad-x86_64-linux===<br />
Xmonad should automatically create the {{Filename|xmonad-i386-linux}} file (in {{Filename|~/.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 {{Filename|.hs}} and all others files in {{Filename|~/.xmonad/}} and run this command from the folder:<br />
xmonad --recompile<br />
<br />
Now you should see the file.<br />
<br />
{{Note|A reason you may get an error message saying that xmonad-x86_64-linux is missing is that {{Package Official|xmonad-contrib}} is not installed.}}<br />
<br />
===Problems with Java applications===<br />
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.<br />
<br />
There are several things that may help:<br />
* If you are using {{Pkg|openjdk6}}, you can export {{Codeline|_JAVA_AWT_WM_NONREPARENTING<nowiki>=</nowiki>1}} in {{Filename|/etc/profile.d/openjdk6.sh}}.<br />
* If you are using {{Pkg|jre7-openjdk}}, you can export {{Codeline|_JAVA_AWT_WM_NONREPARENTING<nowiki>=</nowiki>1}} in {{Filename|/etc/profile.d/jre.sh}}.<br />
* 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<br />
>> setWMName "LG3D"<br />
added to the LogHook may help.<br />
<br />
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.]<br />
<br />
===Empty space at the bottom of gvim or terminals===<br />
See [[Vim#Empty space at the bottom of gvim windows]] for a solution which makes the area match the background color.<br />
<br />
For [[rxvt-unicode]], you can use {{Package AUR|rxvt-unicode-patched}}.<br />
<br />
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].<br />
<br />
===Chromium/Chrome will not go fullscreen===<br />
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 {{Codeline|import}} statement to your {{Filename|~/.xmonad/xmonad.hs}}:<br />
import XMonad.Hooks.EwmhDesktops<br />
and then add {{Codeline|handleEventHook <nowiki>=</nowiki> fullscreenEventHook}} to the appropriate place; for example:<br />
<pre><br />
...<br />
xmonad $ defaultConfig<br />
{ modMask = mod4Mask<br />
, handleEventHook = fullscreenEventHook<br />
}<br />
...<br />
</pre><br />
After a recompile/restart of xmonad, Chromium should now respond to {{ic|F11}} (fullscreen) as expected.<br />
<br />
===Multitouch / touchegg===<br />
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.<br />
<br />
==Other Resources==<br />
[http://xmonad.org/ xmonad] - The official xmonad website<br />
<br />
[http://haskell.org/haskellwiki/Xmonad/Config_archive/Template_xmonad.hs_(0.9) xmonad.hs] - Template xmonad.hs<br />
<br />
[http://xmonad.org/tour.html xmonad: a guided tour]<br />
<br />
[[dzen]] - General purpose messaging and notification program<br />
<br />
[[dmenu]] - Dynamic X menu for the quick launching of programs<br />
<br />
[[Comparison of Tiling Window Managers]] - Arch wiki article providing an overview of mainstream tiling window managers</div>
Ronpaul