xmonad_configuration.html 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <meta name="generator" content="MediaWiki 1.19.14+dfsg-1" />
  6. <link rel="shortcut icon" href="https://wiki.haskell.org/Xmonad/Config_archive/wikistatic/favicon.ico" />
  7. <link rel="search" type="application/opensearchdescription+xml" href="https://wiki.haskell.org/opensearch_desc.php" title="HaskellWiki (en)" />
  8. <link rel="EditURI" type="application/rsd+xml" href="https://wiki.haskell.org/api.php?action=rsd" />
  9. <link rel="copyright" href="https://wiki.haskell.org/HaskellWiki:Copyrights" />
  10. <link rel="alternate" type="application/atom+xml" title="HaskellWiki Atom feed" href="https://wiki.haskell.org/index.php?title=Special:RecentChanges&amp;feed=atom" /> <title>Xmonad/Config archive/John Goerzen's Configuration - HaskellWiki</title>
  11. <style type="text/css" media="screen, projection">/*<![CDATA[*/
  12. @import "../../wikistatic/skins/common/shared.css@303.css";
  13. @import "../../wikistatic/skins/hawiki/main.css@303.css";
  14. /*]]>*/</style>
  15. <link rel="stylesheet" type="text/css" media="print" href="../../wikistatic/skins/common/commonPrint.css@303.css" />
  16. <!--[if lt IE 5.5000]><style type="text/css">@import "/wikistatic/skins//hawiki/IE50Fixes.css?303";</style><![endif]-->
  17. <!--[if IE 5.5000]><style type="text/css">@import "/wikistatic/skins//hawiki/IE55Fixes.css?303";</style><![endif]-->
  18. <!--[if IE 6]><style type="text/css">@import "/wikistatic/skins//hawiki/IE60Fixes.css?303";</style><![endif]-->
  19. <!--[if IE 7]><style type="text/css">@import "/wikistatic/skins//hawiki/IE70Fixes.css?303";</style><![endif]-->
  20. <!--[if lte IE 7]><script type="text/javascript" src="/wikistatic/skins//hawiki/IEFixes.js?303"></script>
  21. <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
  22. <script type="text/javascript">
  23. var isMSIE55 = (window.showModalDialog && window.clipboardData && window.createPopup); /*alert("test: " + isMSIE55);*/</script>
  24. <script>if(window.mw){
  25. mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Xmonad/Config_archive/John_Goerzen\'s_Configuration","wgTitle":"Xmonad/Config archive/John Goerzen\'s Configuration","wgCurRevisionId":41805,"wgArticleId":4166,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["XMonad configuration"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgRelevantPageName":"Xmonad/Config_archive/John_Goerzen\'s_Configuration","wgRestrictionEdit":[],"wgRestrictionMove":[]});
  26. }</script>
  27. <script type="text/javascript" src="../../wikistatic/skins/common/wikibits.js@303"><!-- wikibits js --></script>
  28. <!-- Head Scripts -->
  29. <script src="../../load.php@debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=hawiki&amp;%252A"></script>
  30. <script>if(window.mw){
  31. mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Xmonad/Config_archive/John_Goerzen\'s_Configuration","wgTitle":"Xmonad/Config archive/John Goerzen\'s Configuration","wgCurRevisionId":41805,"wgArticleId":4166,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["XMonad configuration"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgRelevantPageName":"Xmonad/Config_archive/John_Goerzen\'s_Configuration","wgRestrictionEdit":[],"wgRestrictionMove":[]});
  32. }</script><script>if(window.mw){
  33. mw.loader.implement("user.options",function($){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":1,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"highlightbroken":1,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":1,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":1,"showtoolbar":1,"skin":"hawiki","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
  34. "watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false});;},{},{});mw.loader.implement("user.tokens",function($){mw.user.tokens.set({"editToken":"+\\","watchToken":false});;},{},{});
  35. /* cache key: wikidb_haskell:resourceloader:filter:minify-js:7:befcdb5e3b24ff89f900613de9ed4ea3 */
  36. }</script>
  37. <script>if(window.mw){
  38. mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
  39. }</script><style type="text/css">/*<![CDATA[*/
  40. .source-haskell {line-height: normal;}
  41. .source-haskell li, .source-haskell pre {
  42. line-height: normal; border: 0px none white;
  43. }
  44. /**
  45. * GeSHi Dynamically Generated Stylesheet
  46. * --------------------------------------
  47. * Dynamically generated stylesheet for haskell
  48. * CSS class: source-haskell, CSS id:
  49. * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann
  50. * (http://qbnz.com/highlighter/ and http://geshi.org/)
  51. * --------------------------------------
  52. */
  53. .haskell.source-haskell .de1, .haskell.source-haskell .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
  54. .haskell.source-haskell {font-family:monospace;}
  55. .haskell.source-haskell .imp {font-weight: bold; color: red;}
  56. .haskell.source-haskell li, .haskell.source-haskell .li1 {font-weight: normal; vertical-align:top;}
  57. .haskell.source-haskell .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
  58. .haskell.source-haskell .li2 {font-weight: bold; vertical-align:top;}
  59. .haskell.source-haskell .kw1 {color: #06c; font-weight: bold;}
  60. .haskell.source-haskell .kw2 {color: #06c; font-weight: bold;}
  61. .haskell.source-haskell .kw3 {font-weight: bold;}
  62. .haskell.source-haskell .kw4 {color: #cccc00; font-weight: bold;}
  63. .haskell.source-haskell .kw5 {color: maroon; font-weight: bold;}
  64. .haskell.source-haskell .co1 {color: #5d478b; font-style: italic;}
  65. .haskell.source-haskell .co2 {color: #339933; font-weight: bold;}
  66. .haskell.source-haskell .co3 {color: #5d478b; font-style: italic;}
  67. .haskell.source-haskell .coMULTI {color: #5d478b; font-style: italic;}
  68. .haskell.source-haskell .es0 {background-color: #3cb371; font-weight: bold;}
  69. .haskell.source-haskell .br0 {color: green;}
  70. .haskell.source-haskell .sy0 {color: #339933; font-weight: bold;}
  71. .haskell.source-haskell .st0 {color: #3cb371;}
  72. .haskell.source-haskell .nu0 {color: red;}
  73. .haskell.source-haskell .me1 {color: #060;}
  74. .haskell.source-haskell .ln-xtra, .haskell.source-haskell li.ln-xtra, .haskell.source-haskell div.ln-xtra {background-color: #ffc;}
  75. .haskell.source-haskell span.xtra { display:block; }
  76. /*]]>*/
  77. </style> </head>
  78. <body class="mediawiki ltr ns-0 ns-subject page-Xmonad_Config_archive_John_Goerzen_s_Configuration skin-hawiki">
  79. <div id="topbar" class="noprint">
  80. <div class="portlet noprint" id="p-personal">
  81. <h5>Personal tools</h5>
  82. <div class="pBody">
  83. <ul><li><a class="homebutton" href="https://wiki.haskell.org/Haskell">Home</a></li>
  84. <li id="pt-login"><a href="https://wiki.haskell.org/index.php?title=Special:UserLogin&amp;returnto=Xmonad%2FConfig+archive%2FJohn+Goerzen%27s+Configuration">Log in</a></li>
  85. </ul>
  86. </div>
  87. </div>
  88. <div id="p-search">
  89. <div id="searchBody" class="pBody">
  90. <form action="https://wiki.haskell.org/index.php" id="searchform"><div>
  91. <input type='hidden' name="title" value="Special:Search"/>
  92. <input id="searchInput" name="search" type="text" value="" />
  93. <input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" />&nbsp;
  94. <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="Search" />
  95. </div></form>
  96. </div>
  97. </div>
  98. </div>
  99. <div id="globalWrapper">
  100. <div class="portlet" id="p-logo">
  101. <a style="background-image: url(../../wikistatic/haskellwiki_logo.png);" href="https://wiki.haskell.org/Haskell"></a>
  102. </div>
  103. <div id="column-content">
  104. <div id="notice-area" class="noprint">
  105. <!-- ?php $this->data['sitenotice'] = 'This is a test instance. Do not edit, your changes will be lost.'; ? -->
  106. </div>
  107. <div id="content-wrapper">
  108. <div id="p-cactions" class="portlet noprint">
  109. <h5>Views</h5>
  110. <div class="pBody">
  111. <ul>
  112. <li id="ca-nstab-main" class="selected"><a href="John_Goerzen's_Configuration.html">Page</a></li>
  113. <li id="ca-talk" class="new"><a href="https://wiki.haskell.org/index.php?title=Talk:Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;action=edit&amp;redlink=1">Discussion</a></li>
  114. <li id="ca-viewsource"><a href="https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;action=edit">View source</a></li>
  115. <li id="ca-history"><a href="https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;action=history">History</a></li> </ul>
  116. </div>
  117. </div>
  118. <div id="content">
  119. <a name="top" id="top"></a>
  120. <h1 id="firstHeading" class="firstHeading">Xmonad/Config archive/John Goerzen's Configuration</h1>
  121. <div id="bodyContent">
  122. <h3 id="siteSub">From HaskellWiki</h3>
  123. <div id="contentSub"><span class="subpages">&lt; <a href="https://wiki.haskell.org/Xmonad" title="Xmonad">Xmonad</a> | <a href="https://wiki.haskell.org/Xmonad/Config_archive" title="Xmonad/Config archive">Config archive</a></span></div>
  124. <div id="jump-to-nav">Jump to: <a href="John_Goerzen's_Configuration.html#column-one">navigation</a>, <a href="John_Goerzen's_Configuration.html#searchInput">search</a></div> <!-- start content -->
  125. <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><p>I'm going to take you step-by-step through the process of configuring Xmonad, setting up a status bar with xmobar, setting up a tray with trayer, and making it all play nicely together. <a href="John_Goerzen's_Configuration.html#disclaimer">I use this exact configuration</a> on everything from a 1024x600 Eee PC to a 1920x1200 24" workstation, and it works well on all of them.
  126. </p><p>I assume that you have read the <a rel="nofollow" class="external text" href="http://xmonad.org/about.html">About xmonad</a> page as well as the <a rel="nofollow" class="external text" href="http://xmonad.org/tour.html">xmonad guided tour</a> already.
  127. </p><p>Before you begin, here is a screenshot of my desktop:
  128. </p>
  129. <div class="center"><div class="floatnone"><a href="https://wiki.haskell.org/File:John-goerzen-xmonad-screenshot.png" class="image"><img alt="John-goerzen-xmonad-screenshot.png" src="../../wikiupload/thumb/e/ed/John-goerzen-xmonad-screenshot.png/200px-John-goerzen-xmonad-screenshot.png" width="200" height="150" /></a></div></div>
  130. <p>And here is a screenshot that points out what I'm talking about when I talk about the status bar and the tray:
  131. </p>
  132. <div class="center"><div class="floatnone"><a href="https://wiki.haskell.org/File:John-goerzen-xmonad-screenshot-annotated.png" class="image"><img alt="John-goerzen-xmonad-screenshot-annotated.png" src="../../wikiupload/thumb/b/b0/John-goerzen-xmonad-screenshot-annotated.png/200px-John-goerzen-xmonad-screenshot-annotated.png" width="200" height="150" /></a></div></div>
  133. <p><br />
  134. </p>
  135. <table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
  136. <ul>
  137. <li class="toclevel-1 tocsection-1"><a href="John_Goerzen's_Configuration.html#Preliminaries"><span class="tocnumber">1</span> <span class="toctext">Preliminaries</span></a></li>
  138. <li class="toclevel-1 tocsection-2"><a href="John_Goerzen's_Configuration.html#Customizing_xmonad"><span class="tocnumber">2</span> <span class="toctext">Customizing xmonad</span></a></li>
  139. <li class="toclevel-1 tocsection-3"><a href="John_Goerzen's_Configuration.html#Installing_xmobar"><span class="tocnumber">3</span> <span class="toctext">Installing xmobar</span></a></li>
  140. <li class="toclevel-1 tocsection-4"><a href="John_Goerzen's_Configuration.html#Configuring_xmonad_to_use_xmobar"><span class="tocnumber">4</span> <span class="toctext">Configuring xmonad to use xmobar</span></a></li>
  141. <li class="toclevel-1 tocsection-5"><a href="John_Goerzen's_Configuration.html#Configuring_xmobar"><span class="tocnumber">5</span> <span class="toctext">Configuring xmobar</span></a>
  142. <ul>
  143. <li class="toclevel-2 tocsection-6"><a href="John_Goerzen's_Configuration.html#Adding_Keyboard_LED_Indication"><span class="tocnumber">5.1</span> <span class="toctext">Adding Keyboard LED Indication</span></a></li>
  144. </ul>
  145. </li>
  146. <li class="toclevel-1 tocsection-7"><a href="John_Goerzen's_Configuration.html#Configuring_Related_Utilities"><span class="tocnumber">6</span> <span class="toctext">Configuring Related Utilities</span></a></li>
  147. <li class="toclevel-1 tocsection-8"><a href="John_Goerzen's_Configuration.html#Final_Touches"><span class="tocnumber">7</span> <span class="toctext">Final Touches</span></a></li>
  148. <li class="toclevel-1 tocsection-9"><a href="John_Goerzen's_Configuration.html#Tips_on_daily_use"><span class="tocnumber">8</span> <span class="toctext">Tips on daily use</span></a>
  149. <ul>
  150. <li class="toclevel-2 tocsection-10"><a href="John_Goerzen's_Configuration.html#Minimizing_Windows"><span class="tocnumber">8.1</span> <span class="toctext">Minimizing Windows</span></a></li>
  151. <li class="toclevel-2 tocsection-11"><a href="John_Goerzen's_Configuration.html#Use_of_workspaces"><span class="tocnumber">8.2</span> <span class="toctext">Use of workspaces</span></a></li>
  152. </ul>
  153. </li>
  154. <li class="toclevel-1 tocsection-12"><a href="John_Goerzen's_Configuration.html#Trouble.3F"><span class="tocnumber">9</span> <span class="toctext">Trouble?</span></a></li>
  155. </ul>
  156. </td></tr></table>
  157. <h2> <span class="mw-headline" id="Preliminaries">1 Preliminaries </span></h2>
  158. <p>First you'll want to install xmonad. You can find instructions for that on xmonad.org. I'm going to assume xmonad 0.8 here.
  159. </p><p>This guide will work for any operating system. I happen to use Debian, so when I talk about installing software, I can give you Debian commands. But you can run xmonad all over the place; just substitute the appropriate commands for your system.
  160. </p><p>To install xmonad on Debian squeeze, you can just run:
  161. </p><p><code>apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools</code>
  162. </p><p>For Debian wheezy (and recent above), run:
  163. </p><p><code>apt-get install xmonad libghc-xmonad-contrib-dev libghc-xmonad-dev suckless-tools</code>
  164. </p><p>This installs xmonad itself, everything you need to configure it, and dwm-tools, which provides the Mod-P launching feature. If you're not on squeeze or wheezy, consult the <a rel="nofollow" class="external text" href="http://xmonad.org/download.html">xmonad download site</a> -- note that there are etch binaries there, too. If you're downloading the etch binaries, you'll need the etch ghc6 and libghc6-*-dev*.deb binaries as well.
  165. </p><p>Set up xmonad in your .xsession as directed in the xmonad guided tour. You should have xmonad up and running before continuing.
  166. </p>
  167. <h2> <span class="mw-headline" id="Customizing_xmonad">2 Customizing xmonad </span></h2>
  168. <p>So the first thing you will want to do is customize xmonad.
  169. </p><p>Make a directory called ~/.xmonad, and in there, create a file named xmonad.hs. We'll start off with importing some of the utility modules we will use:
  170. </p>
  171. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"><span class="kw1">import</span> XMonad
  172. <span class="kw1">import</span> XMonad.Hooks.DynamicLog
  173. <span class="kw1">import</span> XMonad.Hooks.ManageDocks
  174. <span class="kw1">import</span> XMonad.Util.Run<span class="br0">&#40;</span>spawnPipe<span class="br0">&#41;</span>
  175. <span class="kw1">import</span> XMonad.Util.EZConfig<span class="br0">&#40;</span>additionalKeys<span class="br0">&#41;</span>
  176. <span class="kw1">import</span> System.<span class="kw4">IO</span></pre></div></div>
  177. <p>Next, a basic configuration -- which is the same as the default -- is this:
  178. </p>
  179. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">main <span class="sy0">=</span> <span class="kw1">do</span>
  180. xmonad <span class="sy0">$</span> defaultConfig</pre></div></div>
  181. <p>Over at the <a rel="nofollow" class="external text" href="http://www.xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Doc-Configuring.html">how to write a config file page</a> -- which you should go read right now -- there are instructions for testing your config file. You should be able to save the above file, with the import lines plus the other two, and validate it with ghci, then press Mod-q to load it up. Another way to validate your xmonad.hs is to simply run `xmonad --recompile' in a terminal. You'll see errors if it's bad, and nothing if it's good.
  182. </p><p>Now how about something real? Replace the lines starting with main with:
  183. </p>
  184. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">main <span class="sy0">=</span> <span class="kw1">do</span>
  185. xmonad <span class="sy0">$</span> defaultConfig
  186. <span class="br0">&#123;</span> manageHook <span class="sy0">=</span> manageDocks <span class="sy0">&lt;+&gt;</span> manageHook defaultConfig
  187. , layoutHook <span class="sy0">=</span> avoidStruts <span class="sy0">$</span> layoutHook defaultConfig
  188. <span class="br0">&#125;</span></pre></div></div>
  189. <p><span id="disclaimer"></span>
  190. (Disclaimer: The author in reality does not use this 'comma first' style. However, since it is the style used in xmonad, xmonad-contrib and most all xmonad.hs files, he has kindly consented to allow your friendly wiki gardeners to convert the original Haskell from 'comma last' style. This should make copying pieces from other configs a bit easier.)
  191. </p><p>Also, <i>ghc sees tab characters as eight spaces</i>, so to prevent confusion ensure your editor produces eight space tabs or expands tabs to spaces when editing haskell files. XMonad convention is to always expand tabs and (mostly) indent by four space increments.
  192. Wikibooks has a great explanation of layout rules and <a rel="nofollow" class="external text" href="http://en.wikibooks.org/wiki/Haskell/Indentation">indentation in haskell</a>.
  193. </p>
  194. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"><span class="co1">-- real Goerzen config style</span>
  195. main <span class="sy0">=</span> <span class="kw1">do</span>
  196. xmonad <span class="sy0">$</span> defaultConfig <span class="br0">&#123;</span>
  197. manageHook <span class="sy0">=</span> manageDocks <span class="sy0">&lt;+&gt;</span> manageHook defaultConfig,
  198. layoutHook <span class="sy0">=</span> avoidStruts <span class="sy0">$</span> layoutHook defaultConfig
  199. <span class="br0">&#125;</span></pre></div></div>
  200. <p>What this does is take the default configuration (defaultConfig) and modify two aspects of it -- the manageHook and layoutHook. This particular recipe comes from the <a href="https://wiki.haskell.org/Xmonad/Frequently_asked_questions" title="Xmonad/Frequently asked questions">Xmonad FAQ</a> and adds the support we need for a status bar and dock. For more ways to customize how and where windows are created, see the manageHook examples in <a href="https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips" title="Xmonad/General xmonad.hs config tips">XMonad General Configuration Tips</a>.
  201. </p><p>I'll show my completed file at the end of this page, but for now let's add a few additional things in. By default, the Mod key is Alt, which is also used in Emacs. Sometimes Emacs and xmonad want to use the same key for different actions. Rather than remap every common key, I just change Mod to be the Windows key that's between Ctrl and Alt. So I add this line after layoutHook:
  202. </p>
  203. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"> , modMask <span class="sy0">=</span> mod4Mask <span class="co1">-- Rebind Mod to the Windows key</span></pre></div></div>
  204. <p>The two dashes are a comment to the end of the line.
  205. </p><p>I also want to bind Mod-Shift-z to lock my screen with the screensaver, control-PrintScreen to take a snapshot of one window, and Printscreen to take a snapshot of the entire screen. My config file, starting with main, now looks like:
  206. </p>
  207. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">main <span class="sy0">=</span> <span class="kw1">do</span>
  208. xmonad <span class="sy0">$</span> defaultConfig
  209. <span class="br0">&#123;</span> manageHook <span class="sy0">=</span> manageDocks <span class="sy0">&lt;+&gt;</span> manageHook defaultConfig
  210. , layoutHook <span class="sy0">=</span> avoidStruts <span class="sy0">$</span> layoutHook defaultConfig
  211. , modMask <span class="sy0">=</span> mod4Mask <span class="co1">-- Rebind Mod to the Windows key</span>
  212. <span class="br0">&#125;</span> `additionalKeys`
  213. <span class="br0">&#91;</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>mod4Mask .<span class="sy0">|</span>. shiftMask, xK_z<span class="br0">&#41;</span>, spawn <span class="st0">&quot;xscreensaver-command -lock&quot;</span><span class="br0">&#41;</span>
  214. , <span class="br0">&#40;</span><span class="br0">&#40;</span>controlMask, xK_Print<span class="br0">&#41;</span>, spawn <span class="st0">&quot;sleep 0.2; scrot -s&quot;</span><span class="br0">&#41;</span>
  215. , <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="nu0">0</span>, xK_Print<span class="br0">&#41;</span>, spawn <span class="st0">&quot;scrot&quot;</span><span class="br0">&#41;</span>
  216. <span class="br0">&#93;</span></pre></div></div>
  217. <p>You can find the names for keys in the <a rel="nofollow" class="external text" href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/X11">haskell-X11</a> source package in the files Graphics/X11/Types.hsc and Graphics.X11.ExtraTypes.hsc.
  218. </p><p>To support screen capture, run apt-get install scrot. I will cover setting up the screensaver later in this tutorial.
  219. </p><p>Did you notice the 0 in the xK_Print line? The first part of the (0, xK_Print) tuple states what modifier keys (ctrl, alt, etc.) have to be held down for a pattern to match. For the PrintScreen key, we don't need anything to be held down, and the zero indicates that. The 'sleep' before running the 'scrot -s' command is to leave time for keys to be released before scrot -s tries to grab the keyboard.
  220. </p>
  221. <h2> <span class="mw-headline" id="Installing_xmobar">3 Installing xmobar </span></h2>
  222. <p>Next, it's time to get started with <a rel="nofollow" class="external text" href="http://code.haskell.org/~arossato/xmobar/">xmobar</a>, the status bar. You can use xmobar or dzen2. dzen2 probably has a few more features, but xmobar has lower resource utilization and is considerably easier and more reliable to set up. I found it does more than everything I need, and recommend it.
  223. </p><p>You can download xmobar from its homepage, linked to above. That page also has compilation and installation instructions. As of Sept. 17, 2008, I also maintain a Darcs tree. Most patches have been merged back as of xmobar 0.9.1, but a couple patches that shorten the number formatting are unapplied. You can download my tree and merge with the official tree with:
  224. </p><p><code>
  225. darcs get <a rel="nofollow" class="external free" href="http://darcs.complete.org/xmobar">http://darcs.complete.org/xmobar</a>
  226. </code>
  227. </p><p><code>
  228. darcs pull --repodir=xmobar --all <a rel="nofollow" class="external free" href="http://code.haskell.org/xmobar">http://code.haskell.org/xmobar</a>
  229. </code>
  230. </p><p>If you darcs, apt-get install darcs or get it from your distribution or darcs.net.
  231. </p>
  232. <h2> <span class="mw-headline" id="Configuring_xmonad_to_use_xmobar">4 Configuring xmonad to use xmobar </span></h2>
  233. <p>So, let's talk a little bit about how xmonad and xmobar fit together. You can piece them together in several different ways.
  234. </p><p>xmobar accepts input on its stdin, which it can display at an arbitrary position on the screen. It can also easily display other information. We want xmonad to send xmobar the stuff that I have at the upper left of my screenshot: information about available workspaces, current layout, and window manager.
  235. </p><p>We could, then, have xmonad write this stuff to its stdout, and write <code>xmonad | xmobar</code> in ~/.xsession. But it's more elegant and useful, in my opinion, to have xmonad fire up xmobar itself. This is pretty simple. Our main part of xmonad.hs will now look like:
  236. </p>
  237. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"> <span class="co1">-- make sure to edit paths to xmobar and .xmobarrc to match your system.</span>
  238. <span class="co1">-- If xmobar is in your $PATH, and its config is in ~/.xmobarrc you don't</span>
  239. <span class="co1">-- need the xmobar path or config file, use: xmproc &lt;- spawnPipe &quot;xmobar&quot;</span>
  240. &#160;
  241. main <span class="sy0">=</span> <span class="kw1">do</span>
  242. xmproc <span class="sy0">&lt;-</span> spawnPipe <span class="st0">&quot;/path/to/xmobarbinary /home/jgoerzen/.xmobarrc&quot;</span>
  243. xmonad <span class="sy0">$</span> defaultConfig
  244. <span class="br0">&#123;</span> manageHook <span class="sy0">=</span> manageDocks <span class="sy0">&lt;+&gt;</span> manageHook defaultConfig
  245. , layoutHook <span class="sy0">=</span> avoidStruts <span class="sy0">$</span> layoutHook defaultConfig
  246. , logHook <span class="sy0">=</span> dynamicLogWithPP xmobarPP
  247. <span class="br0">&#123;</span> ppOutput <span class="sy0">=</span> hPutStrLn xmproc
  248. , ppTitle <span class="sy0">=</span> xmobarColor <span class="st0">&quot;green&quot;</span> <span class="st0">&quot;&quot;</span> . shorten <span class="nu0">50</span>
  249. <span class="br0">&#125;</span>
  250. , modMask <span class="sy0">=</span> mod4Mask <span class="co1">-- Rebind Mod to the Windows key</span>
  251. <span class="br0">&#125;</span> `additionalKeys`
  252. <span class="br0">&#91;</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>mod4Mask .<span class="sy0">|</span>. shiftMask, xK_z<span class="br0">&#41;</span>, spawn <span class="st0">&quot;xscreensaver-command -lock&quot;</span><span class="br0">&#41;</span>
  253. , <span class="br0">&#40;</span><span class="br0">&#40;</span>controlMask, xK_Print<span class="br0">&#41;</span>, spawn <span class="st0">&quot;sleep 0.2; scrot -s&quot;</span><span class="br0">&#41;</span>
  254. , <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="nu0">0</span>, xK_Print<span class="br0">&#41;</span>, spawn <span class="st0">&quot;scrot&quot;</span><span class="br0">&#41;</span>
  255. <span class="br0">&#93;</span></pre></div></div>
  256. <p>We've added a line right after "main". We fire up xmobar, and pass to it a command-line argument giving the path to its config file -- we will create this file in a minute. Then we also define a logHook. We tell xmonad that the way we get output to xmobar is with the command hPutStrLn xmproc -- this transmits the data via a pipe to xmobar. We also tell it that we want to put the first 50 characters of the window title in the title area.
  257. </p><p><i><b>When using hPutStrLn in your logHook make sure to add StdinReader to your xmobarrc commands and template as described below or xmonad <a href="https://wiki.haskell.org/Xmonad/Frequently_asked_questions#XMonad_stops_but_the_current_window_still_responds_to_keys" title="Xmonad/Frequently asked questions">may freeze</a> when the unread pipe fills up.</b></i>
  258. </p><p>Save this and test it with ghci.
  259. </p>
  260. <h2> <span class="mw-headline" id="Configuring_xmobar">5 Configuring xmobar </span></h2>
  261. <p>Now, before this will work, we have to configure xmobar. Here's a slightly simplified version of what I use, which is mostly similar to the sample you can find in the xmobar source package.
  262. </p><p><i>For xmobar-0.9 or earlier</i>
  263. </p>
  264. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">Config <span class="br0">&#123;</span> font <span class="sy0">=</span> <span class="st0">&quot;-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*&quot;</span>
  265. , bgColor <span class="sy0">=</span> <span class="st0">&quot;black&quot;</span>
  266. , fgColor <span class="sy0">=</span> <span class="st0">&quot;grey&quot;</span>
  267. , position <span class="sy0">=</span> TopW L <span class="nu0">90</span>
  268. , commands <span class="sy0">=</span> <span class="br0">&#91;</span> Run Weather <span class="st0">&quot;EGPF&quot;</span> <span class="br0">&#91;</span><span class="st0">&quot;-t&quot;</span>,<span class="st0">&quot; &lt;tempF&gt;F&quot;</span>,<span class="st0">&quot;-L&quot;</span>,<span class="st0">&quot;64&quot;</span>,<span class="st0">&quot;-H&quot;</span>,<span class="st0">&quot;77&quot;</span>,<span class="st0">&quot;--normal&quot;</span>,<span class="st0">&quot;green&quot;</span>,<span class="st0">&quot;--high&quot;</span>,<span class="st0">&quot;red&quot;</span>,<span class="st0">&quot;--low&quot;</span>,<span class="st0">&quot;lightblue&quot;</span><span class="br0">&#93;</span> <span class="nu0">36000</span>
  269. , Run Cpu <span class="br0">&#91;</span><span class="st0">&quot;-L&quot;</span>,<span class="st0">&quot;3&quot;</span>,<span class="st0">&quot;-H&quot;</span>,<span class="st0">&quot;50&quot;</span>,<span class="st0">&quot;--normal&quot;</span>,<span class="st0">&quot;green&quot;</span>,<span class="st0">&quot;--high&quot;</span>,<span class="st0">&quot;red&quot;</span><span class="br0">&#93;</span> <span class="nu0">10</span>
  270. , Run Memory <span class="br0">&#91;</span><span class="st0">&quot;-t&quot;</span>,<span class="st0">&quot;Mem: &lt;usedratio&gt;%&quot;</span><span class="br0">&#93;</span> <span class="nu0">10</span>
  271. , Run Swap <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="nu0">10</span>
  272. , Run Date <span class="st0">&quot;%a&#160;%b&#160;%_d&#160;%l:%M&quot;</span> <span class="st0">&quot;date&quot;</span> <span class="nu0">10</span>
  273. , Run StdinReader
  274. <span class="br0">&#93;</span>
  275. , sepChar <span class="sy0">=</span> <span class="st0">&quot;%&quot;</span>
  276. , alignSep <span class="sy0">=</span> <span class="st0">&quot;}{&quot;</span>
  277. , template <span class="sy0">=</span> <span class="st0">&quot;%StdinReader% }{&#160;%cpu% |&#160;%memory% *&#160;%swap% &lt;fc=#ee9a00&gt;%date%&lt;/fc&gt; |&#160;%EGPF%&quot;</span>
  278. <span class="br0">&#125;</span></pre></div></div>
  279. <p><span id="lowerOnStart"></span>
  280. <b>Note:</b> <i><b>With 0.9 &lt; xmobar-version &lt;= 0.9.2 </b></i>, you will need to <b>add a lowerOnStart line</b> just below position:
  281. </p>
  282. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">Config <span class="br0">&#123;</span> font <span class="sy0">=</span> <span class="st0">&quot;-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*&quot;</span>
  283. , bgColor <span class="sy0">=</span> <span class="st0">&quot;black&quot;</span>
  284. , fgColor <span class="sy0">=</span> <span class="st0">&quot;grey&quot;</span>
  285. , position <span class="sy0">=</span> TopW L <span class="nu0">90</span>
  286. , lowerOnStart <span class="sy0">=</span> True
  287. ....<span class="sy0">&lt;</span>snip<span class="sy0">&gt;</span></pre></div></div>
  288. <p><b>Note:</b> <i><b>With xmobar-version &gt; 0.9.2 </b></i>, any fields you leave out will be replaced by defaults, and the order doesn't matter.
  289. </p><p>First, I set the font to use for my bar, as well as the colors. The position options are documented well on the xmobar home page. This says to put my bar in the upper left of the screen, and make it consume 90% of the width of the screen.
  290. </p>
  291. In the <div class="inline-code"><div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell">commands</div></div></div> list you, well, define commands. The commands are the pieces that generate the content that is available to display, which will later be combined together in the template. I define a weather widget, a CPU widget, memory and swap widgets, a clock, and of course the data from xmonad via the StdinReader.
  292. <p>The template then combines them together. Stuff to be left-justified goes before the <b>}</b> character, things to be centered after it, and things to be right justified after <b>{</b>. I have nothing centered so there is nothing in between them.
  293. </p>
  294. <b>Warning:</b> even though the config file uses Haskell syntax, it <i>doesn't accept comments, (and in versions earlier than 0.9.3 doesn't allow you to change the field order, or drop fields.)</i> This is because older versions of xmobar use <div class="inline-code"><div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><span class="kw3">reads</span></div></div></div> to parse the config file.
  295. <p>Save that to ~/.xmobarrc. Now you should be able to press Mod-q and have xmonad load up xmobar, and have it work. (Note: until you add the trayer command to your .xinitrc, as described below, to fill up the other 10% of the screen width, and restart X Windows, your windows may cover the xmobar status bar.)
  296. </p><p>Replace both occurrences of EGPF with your choice of ICAO weather stations. There is a list of ICAO station codes maintained at <a rel="nofollow" class="external text" href="http://www.rap.ucar.edu/weather/surface/stations.txt">ucar.edu</a>. You can of course monitor more than one if you like, see the <a rel="nofollow" class="external text" href="http://code.haskell.org/~arossato/xmobar">xmobar home page</a> for more details.
  297. </p>
  298. <h3> <span class="mw-headline" id="Adding_Keyboard_LED_Indication">5.1 Adding Keyboard LED Indication </span></h3>
  299. <p>My 9.1" Eee doesn't have capslock or numlock lights. Before xmonad, I had an applet to do that, but that's not very efficient now. If you want this, read this section, otherwise skip it.
  300. </p><p>You'll need two pieces of software for this to work:
  301. </p><p>1) xmobar &gt;= 0.9.1
  302. </p><p>2) My ledmon tool, which you can obtain with:
  303. </p><p><code>
  304. git clone <a rel="nofollow" class="external free" href="git://git.complete.org/ledmon">git://git.complete.org/ledmon</a>
  305. </code>
  306. </p><p>Or download from <a rel="nofollow" class="external text" href="http://git.complete.org/ledmon?a=tree">its gitweb page</a>.
  307. </p><p>The CommandReader plugin will be used, which will cause xmobar to fork off ledmon. I compiled ledmon and put the binary in ~/.xmonad/ledmon, then modified my ~/.xmobarrc to look like this:
  308. </p>
  309. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">Config <span class="br0">&#123;</span> font <span class="sy0">=</span> <span class="st0">&quot;-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*&quot;</span>
  310. , bgColor <span class="sy0">=</span> <span class="st0">&quot;black&quot;</span>
  311. , fgColor <span class="sy0">=</span> <span class="st0">&quot;grey&quot;</span>
  312. , position <span class="sy0">=</span> TopW L <span class="nu0">90</span>
  313. , commands <span class="sy0">=</span> <span class="br0">&#91;</span> Run Weather <span class="st0">&quot;EGPF&quot;</span> <span class="br0">&#91;</span><span class="st0">&quot;-t&quot;</span>,<span class="st0">&quot; &lt;tempF&gt;F&quot;</span>,<span class="st0">&quot;-L&quot;</span>,<span class="st0">&quot;64&quot;</span>,<span class="st0">&quot;-H&quot;</span>,<span class="st0">&quot;77&quot;</span>,<span class="st0">&quot;--normal&quot;</span>,<span class="st0">&quot;green&quot;</span>,<span class="st0">&quot;--high&quot;</span>,<span class="st0">&quot;red&quot;</span>,<span class="st0">&quot;--low&quot;</span>,<span class="st0">&quot;lightblue&quot;</span><span class="br0">&#93;</span> <span class="nu0">36000</span>
  314. , Run Cpu <span class="br0">&#91;</span><span class="st0">&quot;-L&quot;</span>,<span class="st0">&quot;3&quot;</span>,<span class="st0">&quot;-H&quot;</span>,<span class="st0">&quot;50&quot;</span>,<span class="st0">&quot;--normal&quot;</span>,<span class="st0">&quot;green&quot;</span>,<span class="st0">&quot;--high&quot;</span>,<span class="st0">&quot;red&quot;</span><span class="br0">&#93;</span> <span class="nu0">10</span>
  315. , Run Memory <span class="br0">&#91;</span><span class="st0">&quot;-t&quot;</span>,<span class="st0">&quot;Mem: &lt;usedratio&gt;%&quot;</span><span class="br0">&#93;</span> <span class="nu0">10</span>
  316. , Run Swap <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="nu0">10</span>
  317. , Run Date <span class="st0">&quot;%a&#160;%b&#160;%_d&#160;%l:%M&quot;</span> <span class="st0">&quot;date&quot;</span> <span class="nu0">10</span>
  318. , Run StdinReader
  319. , Run CommandReader <span class="st0">&quot;/home/jgoerzen/.xmonad/ledmon&quot;</span> <span class="st0">&quot;LED&quot;</span>
  320. <span class="br0">&#93;</span>
  321. , sepChar <span class="sy0">=</span> <span class="st0">&quot;%&quot;</span>
  322. , alignSep <span class="sy0">=</span> <span class="st0">&quot;}{&quot;</span>
  323. , template <span class="sy0">=</span> <span class="st0">&quot;%StdinReader% }{ &lt;fc=#ffff00&gt;%LED%&lt;/fc&gt;&#160;%cpu% |&#160;%memory% *&#160;%swap% &lt;fc=#ee9a00&gt;%date%&lt;/fc&gt; |&#160;%EGPF%&quot;</span>
  324. <span class="br0">&#125;</span></pre></div></div>
  325. <p>That's all there is to it.
  326. </p><p><a href="John_Goerzen's_Configuration.html#lowerOnStart">(for newer versions than xmobar-0.9, add lowerOnStart)</a>
  327. </p>
  328. <h2> <span class="mw-headline" id="Configuring_Related_Utilities">6 Configuring Related Utilities </span></h2>
  329. <p>So now you've got a status bar and xmonad. We still need a few more things: a screensaver, a tray for your apps that have tray icons, a way to set your desktop background, and the like.
  330. </p><p>For this, we will need a few pieces of software.
  331. </p><p><code>
  332. apt-get install trayer xscreensaver
  333. </code>
  334. </p><p>If you want the Gajim instant messenger client, a battery meter, and a network applet, also:
  335. </p><p><code>
  336. apt-get install gajim nm-applet gnome-power-manager
  337. </code>
  338. </p><p>First, configure xscreensaver how you like it with the xscreensaver-demo command. Now, we will set these things up in ~/.xsession. Your .xsession may wind up looking like this:
  339. </p>
  340. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"><span class="sy0">#!/</span>bin<span class="sy0">/</span>bash
  341. &#160;
  342. <span class="sy0">#</span> Load resources
  343. &#160;
  344. xrdb <span class="sy0">-</span>merge .Xresources
  345. &#160;
  346. <span class="sy0">#</span> Set up an icon tray
  347. &#160;
  348. trayer <span class="co1">--edge top --align right --SetDockType true --SetPartialStrut true \</span>
  349. <span class="co1">--expand true --width 10 --transparent true --tint 0x191970 --height 12 &amp;</span>
  350. &#160;
  351. <span class="sy0">#</span> Set the background color<span class="sy0">&lt;</span>
  352. &#160;
  353. xsetroot <span class="sy0">-</span>solid midnightblue
  354. &#160;
  355. <span class="sy0">#</span> Fire up apps
  356. &#160;
  357. gajim <span class="sy0">&amp;</span>
  358. &#160;
  359. xscreensaver <span class="sy0">-</span>no<span class="sy0">-</span>splash <span class="sy0">&amp;</span>
  360. &#160;
  361. <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="sy0">-</span>x <span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>nm<span class="sy0">-</span>applet <span class="br0">&#93;</span>&#160;; <span class="kw1">then</span>
  362. nm<span class="sy0">-</span>applet <span class="co1">--sm-disable &amp;</span>
  363. fi
  364. &#160;
  365. <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="sy0">-</span>x <span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>gnome<span class="sy0">-</span>power<span class="sy0">-</span>manager <span class="br0">&#93;</span>&#160;; <span class="kw1">then</span>
  366. sleep <span class="nu0">3</span>
  367. gnome<span class="sy0">-</span>power<span class="sy0">-</span>manager <span class="sy0">&amp;</span>
  368. fi
  369. &#160;
  370. exec xmonad</pre></div></div>
  371. <p>This uses xsetroot to set my background color. It can also use images; see its manpage for more.
  372. </p><p>Then we fire up trayer, the icon tray. The options tell it to go on the top right, with a default width of 10% of the screen (to nicely match up with the status bar, which we set to a width of 90% of the screen). We give it a color and a height.
  373. </p><p>Then we fire up gajim, the screensaver daemon, and if installed, the network manager applet and the power manager.
  374. </p><p>Finally, we start xmonad.
  375. </p><p>Mission accomplished!
  376. </p>
  377. <h2> <span class="mw-headline" id="Final_Touches">7 Final Touches </span></h2>
  378. <p>There may be some programs that you don't want xmonad to tile. The classic example is Gimp. It pops up all sorts of new windows all the time, and they work best at defined sizes. It makes sense for xmonad to ignore them. Over at <a href="https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips" title="Xmonad/General xmonad.hs config tips">the general tips page</a>, there are suggestions on how to accomplish this. The <a href="https://wiki.haskell.org/Xmonad/Frequently_asked_questions#I_need_to_find_the_class_title_or_some_other_X_property_of_my_program" title="Xmonad/Frequently asked questions">xmonad FAQ</a> has instructions on using xprop to find the class (or other properties) of your window. In the following example if it doesn't work as is, replace Gimp with the class name of your particular install, such as Gimp-2.X or whatever it happens to be. Also note that manageHook runs when windows are created, so you will have to restart the program to be managed if you're dialing in the correct className.
  379. </p><p>We are going to compose a list like so:
  380. </p>
  381. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">myManageHook <span class="sy0">=</span> composeAll
  382. <span class="br0">&#91;</span> className <span class="sy0">=?</span> <span class="st0">&quot;Gimp&quot;</span> <span class="co2">--&gt;</span> doFloat<span class="br0">&#93;</span></pre></div></div>
  383. <p>I also don't want xmonad to tile the VNC viewer, because I want to manage its size myself. Very well; I can add it:
  384. </p>
  385. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1">myManageHook <span class="sy0">=</span> composeAll
  386. <span class="br0">&#91;</span> className <span class="sy0">=?</span> <span class="st0">&quot;Gimp&quot;</span> <span class="co2">--&gt;</span> doFloat
  387. , className <span class="sy0">=?</span> <span class="st0">&quot;Vncviewer&quot;</span> <span class="co2">--&gt;</span> doFloat
  388. <span class="br0">&#93;</span></pre></div></div>
  389. <p>Now, we tie that in with what we're already doing for the manageHook, so our manageHook bit of main looks like:
  390. </p>
  391. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"> xmonad <span class="sy0">$</span> defaultConfig
  392. <span class="br0">&#123;</span> manageHook <span class="sy0">=</span> manageDocks <span class="sy0">&lt;+&gt;</span> myManageHook
  393. <span class="sy0">&lt;+&gt;</span> manageHook defaultConfig</pre></div></div>
  394. <p>The full ~/.xmonad/xmonad.hs now looks like this:
  395. </p>
  396. <div dir="ltr" class="mw-geshi mw-content-ltr"><div class="haskell source-haskell"><pre class="de1"><span class="kw1">import</span> XMonad
  397. <span class="kw1">import</span> XMonad.Hooks.DynamicLog
  398. <span class="kw1">import</span> XMonad.Hooks.ManageDocks
  399. <span class="kw1">import</span> XMonad.Util.Run<span class="br0">&#40;</span>spawnPipe<span class="br0">&#41;</span>
  400. <span class="kw1">import</span> XMonad.Util.EZConfig<span class="br0">&#40;</span>additionalKeys<span class="br0">&#41;</span>
  401. <span class="kw1">import</span> System.<span class="kw4">IO</span>
  402. &#160;
  403. myManageHook <span class="sy0">=</span> composeAll
  404. <span class="br0">&#91;</span> className <span class="sy0">=?</span> <span class="st0">&quot;Gimp&quot;</span> <span class="co2">--&gt;</span> doFloat
  405. , className <span class="sy0">=?</span> <span class="st0">&quot;Vncviewer&quot;</span> <span class="co2">--&gt;</span> doFloat
  406. <span class="br0">&#93;</span>
  407. &#160;
  408. main <span class="sy0">=</span> <span class="kw1">do</span>
  409. xmproc <span class="sy0">&lt;-</span> spawnPipe <span class="st0">&quot;/path/to/xmobarbinary /home/jgoerzen/.xmobarrc&quot;</span>
  410. xmonad <span class="sy0">$</span> defaultConfig
  411. <span class="br0">&#123;</span> manageHook <span class="sy0">=</span> manageDocks <span class="sy0">&lt;+&gt;</span> myManageHook <span class="co1">-- make sure to include myManageHook definition from above</span>
  412. <span class="sy0">&lt;+&gt;</span> manageHook defaultConfig
  413. , layoutHook <span class="sy0">=</span> avoidStruts <span class="sy0">$</span> layoutHook defaultConfig
  414. , logHook <span class="sy0">=</span> dynamicLogWithPP xmobarPP
  415. <span class="br0">&#123;</span> ppOutput <span class="sy0">=</span> hPutStrLn xmproc
  416. , ppTitle <span class="sy0">=</span> xmobarColor <span class="st0">&quot;green&quot;</span> <span class="st0">&quot;&quot;</span> . shorten <span class="nu0">50</span>
  417. <span class="br0">&#125;</span>
  418. , modMask <span class="sy0">=</span> mod4Mask <span class="co1">-- Rebind Mod to the Windows key</span>
  419. <span class="br0">&#125;</span> `additionalKeys`
  420. <span class="br0">&#91;</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>mod4Mask .<span class="sy0">|</span>. shiftMask, xK_z<span class="br0">&#41;</span>, spawn <span class="st0">&quot;xscreensaver-command -lock&quot;</span><span class="br0">&#41;</span>
  421. , <span class="br0">&#40;</span><span class="br0">&#40;</span>controlMask, xK_Print<span class="br0">&#41;</span>, spawn <span class="st0">&quot;sleep 0.2; scrot -s&quot;</span><span class="br0">&#41;</span>
  422. , <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="nu0">0</span>, xK_Print<span class="br0">&#41;</span>, spawn <span class="st0">&quot;scrot&quot;</span><span class="br0">&#41;</span>
  423. <span class="br0">&#93;</span></pre></div></div>
  424. <h2> <span class="mw-headline" id="Tips_on_daily_use">8 Tips on daily use </span></h2>
  425. <p>Here are a few things that occurred to me as I was learning xmonad.
  426. </p>
  427. <h3> <span class="mw-headline" id="Minimizing_Windows">8.1 Minimizing Windows </span></h3>
  428. <p>xmonad doesn't currently have a "minimize" feature. So I've designated workspace 9 for this purpose. When I want to hide a window, I Mod-Shift-9 it. That makes it go away. When I want it back, it's Mod-9, the Mod-j or Mod-k to select it, then Mod-Shift-1 Mod-1 or whatnot to zip it back and go back. It works surprisingly well.
  429. </p>
  430. <h3> <span class="mw-headline" id="Use_of_workspaces">8.2 Use of workspaces </span></h3>
  431. <p>I used to use KDE, and I used workspaces there too. But with the ability to so easily zip windows around to different workspaces, and to instantaneously change between them using only the keyboard, it's a lot easier to use.
  432. </p><p>Also, I find myself not wanting to have quite as many windows open on a given desktop at once. I generally have desktop 1 be for shells, 2 for email/IM, 3 for web, and 9 for music/minimized stuff. But I'm just learning this so far, and may find a better way. Don't hesitate to try different ways of organizing and use what works for you.
  433. </p>
  434. <h2> <span class="mw-headline" id="Trouble.3F">9 Trouble? </span></h2>
  435. <p>Check ~/.xsession-errors first.
  436. </p><p>Also, #xmonad on irc.freenode.net is very friendly and helpful. Ask questions and wait in channel for a while, eventually someone will answer if they have something helpful to say. Sometimes in 10 minutes, sometimes in 10 hours.
  437. </p>
  438. <!--
  439. NewPP limit report
  440. Preprocessor node count: 202/1000000
  441. Post‐expand include size: 0/2097152 bytes
  442. Template argument size: 0/2097152 bytes
  443. Expensive parser function count: 0/100
  444. -->
  445. <!-- Saved in parser cache with key wikidb_haskell:pcache:idhash:4166-0!*!0!1!en!2!* and timestamp 20180712202319 -->
  446. </div><div class="printfooter">
  447. Retrieved from "<a href="https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;oldid=41805">https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;oldid=41805</a>"</div>
  448. <div id='catlinks' class='catlinks'><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="https://wiki.haskell.org/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="https://wiki.haskell.org/Category:XMonad_configuration" title="Category:XMonad configuration">XMonad configuration</a></li></ul></div></div> <!-- end content -->
  449. <div class="visualClear"></div>
  450. </div>
  451. </div>
  452. </div></div>
  453. <div id="column-one">
  454. <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
  455. <div class='generated-sidebar portlet' id='p-navigation'>
  456. <h5>Navigation</h5>
  457. <div class='pBody'>
  458. <ul>
  459. <li id="n-mainpage"><a href="https://wiki.haskell.org/Haskell">Haskell</a></li>
  460. <li id="n-portal"><a href="https://wiki.haskell.org/HaskellWiki:Community">Wiki community</a></li>
  461. <li id="n-recentchanges"><a href="https://wiki.haskell.org/Special:RecentChanges">Recent changes</a></li>
  462. <li id="n-randompage"><a href="https://wiki.haskell.org/Special:Random">Random page</a></li>
  463. </ul>
  464. </div>
  465. </div>
  466. <div class="portlet" id="p-tb">
  467. <h5>Tools</h5>
  468. <div class="pBody">
  469. <ul>
  470. <li id="t-whatlinkshere"><a href="https://wiki.haskell.org/Special:WhatLinksHere/Xmonad/Config_archive/John_Goerzen%27s_Configuration">What links here</a></li>
  471. <li id="t-recentchangeslinked"><a href="https://wiki.haskell.org/Special:RecentChangesLinked/Xmonad/Config_archive/John_Goerzen%27s_Configuration">Related changes</a></li>
  472. <li id="t-specialpages"><a href="https://wiki.haskell.org/Special:SpecialPages">Special pages</a></li>
  473. <li id="t-print"><a href="https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;printable=yes" rel="alternate">Printable version</a></li> <li id="t-permalink"><a href="https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&amp;oldid=41805">Permanent link</a></li> </ul>
  474. </div>
  475. </div>
  476. </div><!-- end of the left (by default at least) column -->
  477. <div class="visualClear"></div>
  478. <div id="footer">
  479. <div id="f-poweredbyico"><a href="https://www.mediawiki.org/"><img src="../../wikistatic/skins/common/images/poweredby_mediawiki_88x31.png" height="31" width="88" alt="Powered by MediaWiki" /></a></div>
  480. <ul id="f-list">
  481. <li id="lastmod"> This page was last modified on 28 August 2011, at 18:31.</li>
  482. <li id="copyright">Recent content is available under <a href="https://wiki.haskell.org/HaskellWiki:Copyrights" title="HaskellWiki:Copyrights">a simple permissive license</a>.</li>
  483. <li id="privacy"><a href="https://wiki.haskell.org/HaskellWiki:Privacy_policy" title="HaskellWiki:Privacy policy">Privacy policy</a></li>
  484. <li id="about"><a href="https://wiki.haskell.org/HaskellWiki:About" title="HaskellWiki:About">About HaskellWiki</a></li>
  485. <li id="disclaimer"><a href="https://wiki.haskell.org/HaskellWiki:General_disclaimer" title="HaskellWiki:General disclaimer">Disclaimers</a></li>
  486. </ul>
  487. </div>
  488. </div>
  489. <script>if(window.mw){
  490. mw.loader.load(["mediawiki.user","mediawiki.page.ready"], null, true);
  491. }</script>
  492. <script src="../../load.php@debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=hawiki&amp;%252A"></script>
  493. <!-- Served in 0.084 secs. --><script type="text/javascript">
  494. var _gaq = _gaq || [];
  495. _gaq.push(['_setAccount', 'UA-83290513-2']);
  496. _gaq.push(['_trackPageview']);
  497. (function() {
  498. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  499. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  500. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  501. })();
  502. </script>
  503. </body></html>