https://wiki.haskell.org/api.php?action=feedcontributions&user=Marcot&feedformat=atomHaskellWiki - User contributions [en]2024-03-28T22:22:21ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Xmonad/Frequently_asked_questions&diff=45601Xmonad/Frequently asked questions2012-05-07T18:10:15Z<p>Marcot: </p>
<hr />
<div>{{xmonad}}<br />
<br />
''xmonad: frequently asked questions''<br />
<br />
''For configuration tricks, and using xmonad.hs, see [[Xmonad/General_xmonad.hs_config_tips]]''.<br />
<br />
''For more documentation, see'':<br />
<br />
* [http://xmonad.org/intro.html Building xmonad]<br />
* [http://xmonad.org/contrib.html Configuring and extending xmonad]<br />
* [http://xmonad.org/xmonad-docs/xmonad-contrib/ Extension documentation]<br />
<br />
==When I start xmonad, nothing happens.==<br />
<br />
Don't panic, this is expected behavior. XMonad is a minimal window manager, meaning it doesn't set a background, start a status bar, display a splash screen or play a soothing sound effect when it starts up. Once xmonad has started, the only thing it does is listen for your first command. Try pressing mod-shift-enter (that is Alt, Shift, and Enter pressed at the same time) to bring up an xterm. Once the xterm appears, use it to read xmonad's man page or point a web browser at http://xmonad.org/tour.html. If no xterm appears, see if any other advice on this page applies.<br />
<br />
==Installation==<br />
<br />
===What build dependencies does xmonad have?===<br />
<br />
The [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/xmonad hackage page for xmonad] lists all dependencies, including:<br />
<br />
* Standard Haskell libraries (you might already have these installed):<br />
** [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Cabal Cabal]<br />
** [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mtl mtl]<br />
** [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix unix]<br />
<br />
* Haskell X11 bindings:<br />
** [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/X11 X11]<br />
<br />
* C libraries:<br />
** libX<br />
** libXext<br />
** libXinerama<br />
<br />
You likely have these already if you've built any programs for X.<br />
<br />
xmonad is also availble pre-packaged for many distributions:<br />
<br />
* [http://www.openbsd.org/cgi-bin/cvsweb/ports/x11/xmonad/ OpenBSD]<br />
* [http://pkgsrc.se/wip/xmonad NetBSD]<br />
* [http://www.freshports.org/x11-wm/xmonad/ FreeBSD]<br />
* [http://packages.gentoo.org/package/xmonad Gentoo]<br />
* [http://packages.debian.org/sid/xmonad Debian]<br />
* [http://packages.ubuntu.com/hardy/xmonad Ubuntu]<br />
* [http://aur.archlinux.org/packages.php?do_Details=1&ID=10593 Arch]<br />
* [http://loupgaroublond.blogspot.com/2007/12/how-to-install-your-very-own-xmonad.html Fedora]<br />
* [http://recipes.gobolinux.org/r/?list=XMonad Gobo]<br />
* [http://nix.cs.uu.nl/nixos/ NixOS]<br />
* [http://codex.sourcemage.org/stable/windowmanagers/xmonad/ Source Mage]<br />
* [http://code.haskell.org/~arossato/xmonad-slack/ Slackware]<br />
<br />
Using your distro package is almost always preferred.<br />
<br />
===Can I install without root permission?===<br />
<br />
Yes, the Haskell libraries that xmonad depends on can all by<br />
installed in the user package database. Simply append --user <br />
to the install phase:<br />
<br />
$ runhaskell Setup.hs install --user<br />
<br />
The library will be registered in your ~/.ghc/ database.<br />
<br />
===How can I use xmonad with a display manager? (xdm, kdm, gdm)===<br />
<br />
The simplest way is to create or modify your ~/.xsession file to run<br />
xmonad. If you don't already have a .xsession, the minimal example<br />
looks like:<br />
<br />
xmonad<br />
<br />
This requires that the ghc and the xmonad executable (or a symlink to them) are in a<br />
directory in the display manager $PATH environment. Alternatively, you can use the full path to xmonad and set ghc's path systemwide. If you do this, you'll also have to change the mod-q binding to use /path/to/xmonad and restart X to have xmonad use the new mod-q (first time only) since the mod-q binding calls xmonad to recompile itself. (See mod-q doesn't work section below.)<br />
<br />
People using 'startx' can use these example [http://code.haskell.org/XMonadContrib/scripts/xinitrc xinitrc] and [http://code.haskell.org/XMonadContrib/scripts/run-xmonad.sh run-xmonad] scripts.<br />
<br />
If you are using xdm, you're done. Login and enjoy xmonad.<br />
<br />
If you're using kdm or gdm (KDE and GNOME's display mangers, respectively),<br />
you're almost done. When logging in, select the entry that says "xsession"<br />
or "default session" from the menu in order to use your ~/.xsession to<br />
start xmonad.<br />
<br />
Alternatively, if you want a menu entry specifically for xmonad, create a<br />
file named "xmonad.desktop" in your /usr/share/xsessions (location varies<br />
by distribution) directory. For example:<br />
<br />
[Desktop Entry]<br />
Encoding=UTF-8<br />
Name=xmonad<br />
Comment=This session starts xmonad<br />
Exec=/usr/local/bin/xmonad<br />
Type=Application<br />
<br />
Replace the "Exec=..." line with the actual path to your xmonad executable,<br />
and you should be able to login by selecting "xmonad" as a session from the<br />
menu in gdm/kdm.<br />
<br />
For instructions on using gdm to launch a full GNOME session with xmonad as<br />
the window manager<br />
[http://haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome#Starting_GNOME_with_xmonad read this].<br />
<br />
===Compiling xmonad on PowerPC and compiler is not interactive===<br />
<br />
If you have ghc installed and are trying to compile xmonad and your compiler <br />
complains about not being interactive, never fear. To compile Setup.hs simply type:<br />
<br />
ghc --make Setup.hs -o Setup<br />
<br />
Now you can:<br />
<br />
./Setup configure<br />
./Setup build<br />
sudo ./Setup install<br />
<br />
If during the build process ghc complains about the "impossible<br />
happening", and mentions that you should change something to "-fvia-C",<br />
just edit the *.cabal file replacing the line that sets the arguments<br />
for ghc, changing "-fasm" to "-fvia-C".<br />
<br />
=== How do I uninstall xmonad? ===<br />
<br />
If you have installed xmonad using your package manager, then just use it.<br />
The following applies if you have built xmonad from source code (either darcs or stable release). Let's assume you've installed xmonad to <br />
<br />
the <code>$PREFIX</code> (that is, gave <code>--prefix=$PREFIX</code> argument to <code>Setup.lhs configure</code>). If unsure, try your <br />
<br />
<code>$HOME</code> and <code>/usr/local</code> as <code>$PREFIX</code>.<br />
<br />
rm -f $PREFIX/bin/xmonad<br />
rm -rf $HOME/.xmonad<br />
rm -rf $PREFIX/lib/xmonad-$VERSION<br />
# If you have installed XMonadContrib:<br />
rm -rf $PREFIX/lib/xmonad-contrib-$VERSION<br />
<br />
If you have installed xmonad 0.5 or newer, also run<br />
ghc-pkg unregister xmonad<br />
# If you have installed XMonadContrib:<br />
ghc-pkg unregister xmonad-contrib<br />
<br />
Do not forget to purge that evil source code!<br />
<br />
=== not found errors or changes to xmonad.hs won't take effect ===<br />
<br />
Ensure that ghc, and the xmonad executable are both in the environment PATH from which you start X. Alternatively symlink them to locations already in the PATH. <code>ghc-pkg list</code> should show ghc, xmonad, X11, etc. without brackets, e.g. {xmonad} is bad. <code>ghc-pkg check</code> will tell you if you have inconsistent dependencies or other registration problems.<br />
<br />
The mod-q action calls the xmonad binary to recompile itself, so if your display manager is starting it with /path/to/xmonad you'll also have to edit your xmonad.hs mod-q binding to use the full path and restart X (or in newer versions use 'xmonad --restart') to restart xmonad with the new mod-q full path binding.<br />
<br />
'''If you recently changed ghc versions''' see [[#Upgraded GHC and now xmonad xmonad-contrib etc are not found]]<br />
<br />
===Configuring xmonad requires GHC, which is 200MB!===<br />
<br />
Yes. You can use [http://braincrater.wordpress.com/2008/09/17/xmonad-light-08-released/ xmonad-light], which allows some of the basic configurations, but if you really want to get the best xmonad experience, you need GHC.<br />
<br />
==Configuration==<br />
<br />
===How do I configure xmonad?===<br />
<br />
By creating and editing the ~/.xmonad/xmonad.hs file, a Haskell source file.<br />
<br />
You can use any Haskell you want in this module. The xmonad-contrib package contains many [http://xmonad.org/xmonad-docs/xmonad-contrib/ extension modules] to make customizing xmonad easier. To have your changes take effect, save the xmonad.hs and either restart (mod-q) or exit X and log back in.<br />
<br />
[[Xmonad/Config_archive|Example configurations]] are available on the wiki.<br />
<br />
For extensive information on configuring, see the links at the top of this page, and [http://haskell.org/haskellwiki/Xmonad/General_xmonad.hs_config_tips the configuration tips] page.<br />
<br />
===Rebinding the mod key (Alt conflicts with other apps; I want the ___ key!)===<br />
<br />
xmonad uses 'alt', actually mod1, as the default modifier. You may<br />
bind to other mod keys by editing your xmonad.hs modMask value, or by<br />
using xmodmap to rebind a key to mod1. The apple command key can be<br />
rebound to mod1 in this way. Use xmodmap to find what key your mod1<br />
is bound to, as well.<br />
<br />
You can rebind the Caps Lock key, to mod, if you wish. See this<br />
[http://lists.suckless.org/dwm/0706/2715.html mailing list item].<br />
<br />
If your new key binding doesn't appear to work, double check it doesn't<br />
clash with an existing binding.<br />
<br />
An example, binding to the mod4 (often 'Win') key:<br />
<br />
<haskell><br />
import XMonad<br />
<br />
main = xmonad defaultConfig<br />
{ modMask = mod4Mask<br />
, terminal = "urxvt"<br />
}<br />
</haskell><br />
<br />
===Multi head and workspaces (desktops)===<br />
See also [[#Multi_head_or_xinerama_troubles|xinerama troubles]] if your multi-head setup doesn't behave as described below.<br />
<br />
XMonad's defaults with multiple monitors may seem confusing and chaotic until explained and illustrated. First we'll look at how things work by default, then at common workspace keybinding customizations.<br />
<br />
To ''focus'' visible workspaces rather than ''swapping'' their screens modify your keybindings as shown in [[#Replacing greedyView with view|the next section below]]. See the section about [[#Other multi head customizations|other customizations]] to give each monitor its own set of workspaces.<br />
<br />
The xmonad man page nicely summarizes how multi-head works by default:<br />
:When running with multiple monitors (Xinerama, TwinView, xrandr), each screen has exactly one workspace visible. Pressing '''<code>mod-{w,e,r}</code>''' switches the focus between screens, while pressing '''<code>shift-mod-{w,e,r}</code>''' moves the current window to that screen. When xmonad starts, workspace 1 is on screen 1, workspace 2 is on screen 2, etc. When switching workspaces to one that is already visible, the current and visible workspaces are swapped.<br />
<br />
'''visible workspaces swap''' (default keybindings): When you have multiple workspaces visible and mod-n to a different ''visible'' workspace, your current one swaps with the other one. We'll see how to change that below, if you don't like the swapping -- simply change 'greedyView' to 'view' in your workspace key bindings. To illustrate with two monitors, using the convention "[1*] [3 ]" to mean workspaces 1 and 3 are visible with left monitor the currently active one:<br />
<br />
<pre><br />
-- 'greedyView' (default) workspace switching (easier to swap visible workspaces)<br />
<br />
-- Typical keystrokes are mod-{w,e,r} to a screen, then mod-N a workspace<br />
<br />
[1*] [3 ] -- mod-3 --> [3*] [1 ] -- mod-e, mod-4 --> [3 ] [4*]<br />
<br />
[3 ] [4*] -- mod-w, mod-4 --> [4*] [3 ]<br />
</pre><br />
<br />
'''my focus moves instead''' (custom workspace switching bindings): By replacing the 'greedyView' function with 'view' in the workspace switching bindings you can have your focus shift to the monitor displaying the given workspace, instead of having that workspace 'brought to you.' (See the next section for examples of how to do this.) For example:<br />
<br />
<pre><br />
-- 'view' workspace switching <br />
<br />
-- (easier to focus another visible workspace, harder to swap)<br />
<br />
[1*] [3 ] -- mod-3 --> [1 ] [3*] -- mod-4 --> [1 ] [4*]<br />
<br />
[1 ] [4*] -- mod-w --> [1*] [4 ] -- mod-4 --> [1 ] [4*]<br />
</pre><br />
<br />
<hask>view</hask> users may also want to add key bindings such as shiftNextScreen and swapNextScreen from the xmonad-contrib extension [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-CycleWS.html XMonad.Actions.CycleWS].<br />
<br />
====Replacing greedyView with view====<br />
Here is an example of changing your workspace switching bindings to use <hask>view</hask> rather than <hask>greedyView</hask> '''using XMonad.Util.EZConfig's additionalKeysP:''' <br />
<br />
(See [http://hackage.haskell.org/package/xmonad-contrib contrib docs] for EZConfig for more details)<br />
<br />
<haskell><br />
import XMonad<br />
-- skipped<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Util.EZConfig<br />
<br />
main = do<br />
xmonad $ defaultConfig {<br />
workspaces = myWorkspaces<br />
-- skipped<br />
} `additionalKeysP` myKeys<br />
<br />
myWorkspaces = ["1","2","3","4","5","6","7","8","9"]<br />
<br />
myKeys = [<br />
<br />
-- other additional keys<br />
<br />
] ++ -- (++) is needed here because the following list comprehension<br />
-- is a list, not a single key binding. Simply adding it to the<br />
-- list of key bindings would result in something like [ b1, b2,<br />
-- [ b3, b4, b5 ] ] resulting in a type error. (Lists must<br />
-- contain items all of the same type.)<br />
<br />
[ (otherModMasks ++ "M-" ++ [key], action tag)<br />
| (tag, key) <- zip myWorkspaces "123456789"<br />
, (otherModMasks, action) <- [ ("", windows . W.view) -- was W.greedyView<br />
, ("S-", windows . W.shift)]<br />
]<br />
</haskell><br />
<br />
'''For use with additionalKeys or default binding style:'''<br />
<br />
<haskell><br />
-- as above<br />
myKeys =<br />
[<br />
-- other additional keys<br />
]<br />
++<br />
[((m .|. mod1Mask, k), windows $ f i) -- Replace 'mod1Mask' with your mod key of choice.<br />
| (i, k) <- zip myWorkspaces [xK_1 .. xK_9]<br />
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]<br />
</haskell><br />
<br />
====Other multi head customizations====<br />
By default, XMonad doesn't link all your monitor screens into one workspace like Gnome and friends, neither does it use a model like dwm's where each monitor has its own set of workspaces. To set up dwm style workspaces for each screen, see (0.9 or greater) [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-IndependentScreens.html Layout.IndependentScreens]<br />
<br />
==== Screens are in wrong order ====<br />
With xmonad-contrib newer than 0.8.*, (darcs version), see also<br />
[http://haskell.org/haskellwiki/Xmonad/Notable_changes_since_0.8 XMonad.Actions.PhysicalScreens]<br />
<br />
Sometimes drivers don't do what you want, and your screens left to right are something<br />
weird like 1 0 2, so your mod-{w,e,r} bindings are messed up. Your driver may provide a utility to set screen order, but if not, or if you just don't want to mess with<br />
it, here's how to rebind the screen switching bindings:<br />
<br />
Note that if you choose not to use myKeys for the key lists appended together with <hask>++</hask> you will need to add parentheses to get something in the form <hask>`additionalKeys` ( [......] ++ [.......] )</hask>.<br />
<br />
'''Using XMonad.Util.EZConfig's additionalKeysP:'''<br />
<haskell><br />
import XMonad<br />
-- skipped<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Util.EZConfig<br />
<br />
main = do<br />
xmonad $ defaultConfig {<br />
-- skipped<br />
} `additionalKeysP` myKeys<br />
<br />
modm = mod4Mask<br />
<br />
myKeys =<br />
[<br />
-- other additional keys<br />
]<br />
++<br />
[ (mask ++ "M-" ++ [key], screenWorkspace scr >>= flip whenJust (windows . action))<br />
| (key, scr) <- zip "wer" [1,0,2] -- was [0..] *** change to match your screen order ***<br />
, (action, mask) <- [ (W.view, "") , (W.shift, "S-")]<br />
]<br />
</haskell><br />
<br />
'''Using default key binding method or XMonad.Util.EZConfig's additionalKeys:'''<br />
<haskell><br />
-- as above<br />
myKeys =<br />
[<br />
-- other additional keys<br />
]<br />
++<br />
[((m .|. mod1Mask, key), screenWorkspace sc >>= flip whenJust (windows . f)) -- Replace 'mod1Mask' with your mod key of choice.<br />
| (key, sc) <- zip [xK_w, xK_e, xK_r] [1,0,2] -- was [0..] *** change to match your screen order ***<br />
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]<br />
</haskell><br />
<br />
===I don't want the focus to follow the mouse===<br />
<br />
Easy. There is a setting focusFollowsMouse in the xmonad.hs file; set it to False and restart with mod+q.<br />
<br />
=== How do I configure pointer-follows-focus? ===<br />
If you are using > xmonad-0.7, you can use the already defined XMonad.Actions.UpdatePointer:<br />
<haskell><br />
myLogHook = dynamicLogWithPP .... >> updatePointer<br />
</haskell><br />
<br />
For xmonad-0.7, in your config, import [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-Warp.html XMonad.Actions.Warp] from Xmonad contrib and <br />
<br />
add this function:<br />
<haskell><br />
pointerFollowsFocus :: Rational -> Rational -> X ()<br />
pointerFollowsFocus h v = do<br />
dpy <- asks display<br />
root <- asks theRoot<br />
withFocused $ \w -> do<br />
wa <- io $ getWindowAttributes dpy w<br />
(sameRoot,_,w',_,_,_,_,_) <- io $ queryPointer dpy root<br />
if (sameRoot && w == w') then<br />
return ()<br />
else<br />
io $ warpPointer dpy none w 0 0 0 0<br />
(fraction h (wa_width wa)) (fraction v (wa_height wa))<br />
where fraction x y = floor (x * fromIntegral y)</haskell><br />
<br />
Then set the logHook in your config to &ldquo;pointerFollowsFocus <i>x</i> <i>y</i>&rdquo;. If you already have a logHook, append &ldquo; <br />
<br />
>> pointerFollowsFocus <i>x</i> <i>y</i>&rdquo; to it. For example:<br />
<haskell>myLogHook = dynamicLogWithPP defaultPP { ppCurrent = xmobarColor "#60ff45" ""<br />
, ppVisible = xmobarColor "#fffff0" "" } >> pointerFollowsFocus 1 1</haskell><br />
<br />
===Does xmonad support a statusbar?===<br />
<br />
Yes. The Hooks.DynamicLog and Hooks.ManageDocks modules are your friends for this purpose. <br />
<br />
Arbitrary external programs may be used as a statusbar. See for example<br />
[http://gotmor.googlepages.com/dzen dzen] or<br />
[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/xmobar xmobar], an<br />
extensible status bar.<br />
<br />
xmonad lets you use any application as a 'statusbar', as long as it is<br />
visible in a given 'gap' on the screen, and has the override-redirect<br />
property set to true. Many status bar/dock programs already set this<br />
property, for example, dzen. To set other applications, you can<br />
sometimes use normal X resources. For example, to use xclock, launch it<br />
with <br />
<br />
xclock -digital -xrm '*overrideRedirect: True' -geometry 1024x30+0+0<br />
<br />
'''If, like xclock, your app doesn't set wm strut properties''', so that ManageDocks and avoidStruts automatically leaves a gap, '''you can do it manually. Import the Layout.Gaps module and, set a gap of, e.g. (30,0,0,0), in xmonad.hs.''' A similar trick can be done for xsystray.<br />
<br />
Also see the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-Monitor.html Layout.Monitor] module.<br />
<br />
You can see screenshots of statusbars on [[Xmonad/Screenshots|the screenshots page]].<br />
<br />
You can also use [http://haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome Gnome] or KDE trays and menus with xmonad. The [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html Hooks.EwmhDesktops], [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Config-Desktop.html Config.Desktop], [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Config-Gnome.html Config.Gnome], [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Config-Kde.html Config.Kde], etc. modules make desktop environment status bars more useful with xmonad.<br />
<br />
To display xmonad logHook output in gnome-panel, see [http://uhsure.com/xmonad-log-applet.html xmonad log applet].<br />
<br />
==== dzen status bars ==== <br />
<br />
xmonad's XMonadContrib library comes with a<br />
really easy function for getting a status bar working with dzen. To use<br />
it, simply have a ~/.xmonad/xmonad.hs containing:<br />
<haskell><br />
import XMonad<br />
import XMonad.Hooks.DynamicLog<br />
<br />
-- 0.9 main:<br />
main = xmonad =<< dzen defaultConfig<br />
-- 0.8.1 main:<br />
main = dzen xmonad<br />
</haskell><br />
which will launch xmonad with dzen2 if found, set up with nice colours<br />
and workspace information. See [[Xmonad/Config_archive/Don%27s_xmonad.hs|Don's config example]] for more information or [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#v%3Adzen DynamicLog dzen's] documentation.<br />
<br />
There is an excellent command-line option and in-text command reference for the SVN version of dzen2 [http://dzen.geekmode.org/dwiki/doku.php?id=dzen:command-and-option-list here]<br />
<br />
====gkrellm or other monitors that aren't bars====<br />
<br />
Gkrellm does not behave like a dock by default. However, there is an option in <code>.gkrellm2/user_config</code> which says <code>dock = 0</code>. If you set it to 1 xmonad will recognize gkrellm as a dock. <br />
<br />
Unfortunately gkrellm usually won't hide under other windows regardless of any combination of <code>above</code> and <code>below</code> options in said config file. Opening and closing the gkrellm config usually resolves this (right click the top of gkrellm and select Configure.. from the menu).<br />
<br />
In xmonad-darcs (will release as xmonad-0.9) the Layout.Monitor module may be helpful.<br />
<br />
====Make space for a panel dock or tray====<br />
<br />
[http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ManageDocks.html ManageDocks] makes it possible for Xmonad to work with panels in the way they expect, automatically leaving the appropriate amount of room for them at the edges of the screen. ''ManageDocks'' has been enabled in the example configuration above. By itself, configuration looks like this:<br />
<br />
<haskell><br />
import XMonad<br />
import XMonad.Hooks.ManageDocks<br />
main = xmonad defaultConfig<br />
{ manageHook = manageDocks <+> manageHook defaultConfig<br />
, layoutHook = avoidStruts $ layoutHook defaultConfig<br />
}<br />
</haskell><br />
<br />
=== Make new windows appear 'below' rather than 'above' the current window ===<br />
See also the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-InsertPosition.html Hooks.InsertPosition] module for placement hooks other than W.SwapDown to use in stack order manageHooks.<br />
<br />
==== Force a few tiled windows down ====<br />
If you only need to position a few windows below rather than above, and can specify window properties that will avoid matching floating dialogs, etc. then adding a few swapDown manageHooks (or similar from Hooks.InsertPosition referenced above) should do the trick.<br />
<br />
<haskell><br />
import XMonad<br />
import qualified XMonad.StackSet as W<br />
main = xmonad defaultConfig<br />
{ manageHook = composeAll<br />
[ resource =? "downer" --> doF W.swapDown<br />
, title =? "obnoxious window" --> doF W.swapDown<br />
, className =? "MPlayer" --> doFloat<br />
]<br />
}<br />
</haskell><br />
<br />
==== Limit windows forced down by using composeOne ====<br />
To position as many windows as possible below the focus while avoiding problems with z-order while using multiple floating windows, use [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ManageHelpers.html Hooks.ManageHelpers] composeOne and (-?>) in place of composeAll and (-->) to specify hooks that only fire if earlier ones have not matched. You can use this to add swapDown last in your composeOne list, so that it's applied only to windows that haven't earlier been floated or identified as transient or dialog windows.<br />
<br />
<haskell><br />
import XMonad<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Hooks.ManageDocks (checkDock)<br />
import XMonad.Hooks.ManageHelpers<br />
<br />
main = xmonad defaultConfig<br />
-- no dialogs, gimp or mplayer windows will get swapped down<br />
-- since they matched earlier in the composeOne list<br />
{ manageHook = composeOne<br />
[ checkDock -?> doIgnore -- equivalent to manageDocks<br />
, isDialog -?> doFloat<br />
, className =? "Gimp" -?> doFloat<br />
, className =? "MPlayer" -?> doFloat<br />
, return True -?> doF W.swapDown<br />
]<br />
}<br />
</haskell><br />
<br />
For a more complex composeOne example, see [http://mauke.ath.cx/stuff/xmonad/xmonad.hs mauke's manageHooks].<br />
<br />
==== Force all new windows down ====<br />
(<hask>doF W.swapDown</hask> is the same as using <hask>insertPosition Lower ____</hask>.) To avoid problems with floating window dialogs it's highly recommended to also add an <hask>isDialog</hask> hook as shown below. Adding <hask>doF W.swapDown</hask> to your manageHook will result in new windows being inserted below the focus; for floating windows this means behind the current window. A minimal config would look like this:<br />
<br />
<haskell><br />
import XMonad<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Hooks.ManageHelpers<br />
<br />
main = xmonad defaultConfig<br />
{ manageHook = isDialog --> doF W.shiftMaster <+> doF W.swapDown<br />
-- <br />
-- To prevent unwanted swaps on other workspaces when using<br />
-- this hook with other doShift hooks, make sure to put<br />
-- doF W.swapDown furthest to the right, or last in a <br />
-- composeAll hook list<br />
}<br />
</haskell><br />
<br />
'''Warning:''' <code>doF W.swapDown</code> without restrictions will result in new floating windows popping up ''behind'' focused floating windows, and undesirable focus changes when starting and quickly destroying a window. It is better to only match specific windows to swapDown or use composeOne as shown above.<br />
<br />
==== Avoid the master window, but otherwise manage new windows normally ====<br />
Note that this is not a good solution for people who use floating windows, since many operations on floats put the floating window into the master position. Some transient windows will be swappedDown to appear below the floating parent unless the user keeps a tiled window in master and floating windows lower in the stack at all times. As with swapDown it's best to use it only on specific windows or at the end of a composeOne list if you use floating windows very often.<br />
<br />
<haskell><br />
-- <snip> <br />
import qualified XMonad.StackSet as W<br />
import XMonad.Hooks.ManageHelpers<br />
-- <snip><br />
<br />
myManageHook = fmap not isDialog --> doF avoidMaster<br />
<br />
-- or if you have other stuff in the managehook, more like<br />
-- myManageHook = (otherStuff) <+> (fmap not isDialog --> doF avoidMaster)<br />
<br />
avoidMaster :: W.StackSet i l a s sd -> W.StackSet i l a s sd<br />
avoidMaster = W.modify' $ \c -> case c of<br />
W.Stack t [] (r:rs) -> W.Stack t [r] rs<br />
otherwise -> c<br />
</haskell><br />
<br />
=== Prevent new windows from stealing focus ===<br />
Use a <hask>doF W.focusDown</hask> manageHook on selected windows, or even<br />
on all windows, similar to the swapDown examples above.<br />
<br />
For an avoidMaster that keeps the focus with the master instead of focusing<br />
the newly created window replace <hask>W.Stack t [] (r:rs) -> W.Stack t [r] rs</hask><br />
with <hask>W.Stack t [] (r:rs) -> W.Stack r [] (t:rs)</hask> in the above avoidMaster code.<br />
<br />
===Firefox annoyances===<br />
<br />
====Stop Firefox from taking focus while using EwmhDesktops====<br />
If one uses EWM Hints support, firefox is enabled to choose when you view its workspace, i.e. if you open links from emails or irc or whatever. If you find it annoying... In about:config (vimperator :preferences!) set <code>browser.tabs.loadDivertedInBackground</code> to True to be able to load urls while working elsewhere, then browse them all later when ''you'' choose to shift to the firefox workspace. Also ubuntu users may need to disable the <code>ubufox</code> extension.<br />
<br />
====Firefox's annoying popup downloader====<br />
<br />
Some applications, notably Firefox 1 and 2, create tranisent windows not<br />
set with the transient property. (e.g. firefox's download manager). When<br />
these windows appear, they can take focus and be annoying. For the case<br />
of firefox, the 'Download Statusbar' extension is useful for disabling<br />
this annoying UI feature.<br />
<br />
=== Watch fullscreen flash video ===<br />
Since approximately November 2010 flash, etc. should tile or full screen without needing any of the following edits to xmonad.hs. However, if you're here you must be having problems. Try some or all of the following hooks that worked in the past.<br />
<br />
For browser plugins and most apps, including mplayer floated by manage hook (as in the default manageHook) the following setup allows normal toggling of fullscreen. A few mplayer versions are configured to use a different fullscreen method, but they can be made to work with the isFullscreen hook by adding a line <code>fstype=none</code> to ~/.mplayer/config, or using the <code>-fstype=none</code> flag from the command line. See also the end of the faq regarding using handleEventHook instead.<br />
<br />
Add one of the following manageHooks, and modify layoutHook with smartBorders:<br />
<haskell><br />
-- other imports<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Hooks.ManageHelpers<br />
import XMonad.Layout.NoBorders<br />
<br />
main = xmonad defaultConfig {<br />
-- skipped<br />
, layoutHook = smartBorders (yourExistingLayoutHook) -- Don't put borders on fullFloatWindows<br />
, manageHook = myManageHooks<br />
}<br />
<br />
myManageHooks = composeAll<br />
-- Allows focusing other monitors without killing the fullscreen<br />
-- [ isFullscreen --> (doF W.focusDown <+> doFullFloat)<br />
<br />
-- Single monitor setups, or if the previous hook doesn't work<br />
[ isFullscreen --> doFullFloat<br />
-- skipped<br />
]<br />
</haskell><br />
If you have multi-head and the focusDown hook doesn't work for you, in darcs xmonad/xmonad-contrib (greater than 0.9.1) XMonad.Hooks.EwmhDesktops has a fullscreenEventHook that is also worth a try. Add it to any existing handleEventHook with <+>, or simply use it as your handleEventHook if you don't already have one. This also is useful for people who prefer tiling mplayer when not fullscreened, or use totem, vlc, or other players that require something like fullscreenEventHook to work at all.<br />
<br />
=== Floating a window or sending it to a specific workspace by default ===<br />
<br />
See [[Xmonad/General_xmonad.hs_config_tips | General xmonad.hs config tips]] regarding manageHook, and the section [[#I need to find the class title or some other X property of my program | here]] about 'xprop' for this.<br />
<br />
===Startup programs===<br />
<br />
You may launch programs at startup in the usual X manner: by adding<br />
them to your .xsession or .Xinitrc. For example, the following<br />
.xsession file launches xpmroot to<br />
set the background image, xmodmap to rebind caps lock to ctrl. It<br />
then launches a status bar program with dzen, before finally<br />
launching xmonad:<br />
<br />
# .xsession<br />
xpmroot ~/.bg/407511721_eb8559457c_o.xpm &amp;<br />
xrdb -merge .Xresources<br />
<br />
xmodmap -e "remove Lock = Caps_Lock"<br />
xmodmap -e "keysym Caps_Lock = Control_L"<br />
xmodmap -e "add Control = Control_L"<br />
<br />
status | dzen2 -ta r -fg '#a8a3f7' \<br />
-bg '#3f3c6d' \<br />
-fn '-*-terminus-medium-r-normal--16-*' \<br />
-e "button1=exec:xterm" &amp; <br />
urxvt &amp;<br />
<br />
$HOME/bin/xmonad<br />
<br />
You may also launch applications from your xmonad.hs, using startupHook, however this runs each time xmonad is restarted with mod-q. Also in > xmonad-0.8 see spawnPid, mkSpawner, spawnOn.<br />
<br />
Use manageHook to arrange your programs on different workspaces by matching various window properties such as className, appName (resource), title, or role.<br />
<br />
===Using floating windows===<br />
Use the regular swap or focus up and down to navigate them, and regular mod-enter to raise a window to the front. For a mod-enter binding, the darcs shiftMaster works better than swapMaster if you use multiple floats over tiled windows. See also this<br />
[[#Force_all_new_windows_down|swapDown manage hook warning]] above. If you use that manageHook on all windows you will create new floats behind existing ones. If you use lots of floats for some reason for better float usability see SimpleFloat layout, FloatKeys, Hooks.Place, and Config.Bluetile in xmonad-contrib.<br />
<br />
===Setting the X cursor===<br />
<br />
By default xmonad doesn't set a particular X cursor, which usually<br />
means the default X cursor will be used by the system. To set your<br />
own custom cursor, use the xsetroot program, as follows, from your<br />
startup file, i.e. .xinitrc, .xsession, display manager startup or<br />
.Desktop files:<br />
<br />
# For example, a nice left-pointing arrow head cursor<br />
<br />
xsetroot -cursor_name left_ptr<br />
<br />
If you have development headers for X11, other cursors can be found in /usr/include/X11/cursorfont.h<br />
<br />
Note that some display managers, such as "slim", don't unset the changes<br />
they make to the cursor when the window manager starts. This can be worked<br />
around by setting the cursor, as above.<br />
<br />
=== Removing the borders around mplayer ===<br />
<br />
You can also use the fullscreen layout, with the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-NoBorders.html NoBorders] smartBorders layout modifier, which automatically takes care of most cases.<br />
<br />
To add 'smartBorders' to the default tiling modes:<br />
<haskell><br />
import XMonad<br />
import XMonad.Layout.NoBorders<br />
<br />
main = xmonad $ <br />
defaultConfig<br />
{ layoutHook = smartBorders $ layoutHook defaultConfig<br />
-- other fields like terminal, modMask, etc.<br />
}<br />
</haskell><br />
<br />
<br />
<br />
You can also remove borders with a key binding using [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-NoBorders.html Actions.NoBorders] extension. There's drawback: you need manually remove border any time you launch mplayer.<br />
<br />
Although this action should be able to be automated, unfortunately you cannot<br />
currently use manageHook for this purpose. That's because borders are drawn<br />
''after'' runManageHook is executed (see Operations.hs for details).<br />
<br />
Alternatively you can manually move the mplayer window 1 pixel to the left and<br />
one pixel up by importing XMonad.Actions.FloatKeys and adding a keybinding<br />
similar to ((modm, xK_b), withFocused (keysMoveWindow (-1,-1)). (I have not<br />
tested yet if this can be used in combination with the manageHook.)<br />
<br />
===I need to find the class title or some other X property of my program===<br />
<br />
When using XMonad.Layout.IM, ManageHooks, XMonad.Actions.WindowGo, or several other modules you need to specify detailed information about a window's properties.<br />
<br />
See below for a script to nicely format output from the <tt>xprop</tt> program discussed in detail in this FAQ.<br />
<br />
Otherwise, you can generally find what you need by splitting your screen between the window and a terminal; in the terminal, run <tt>xprop WM_CLASS</tt> or the like, and then click on the window. xprop will print out quite a bit of useful information about the window. <br />
* '''resource''' (also known as '''appName''') is the first element in WM_CLASS(STRING)<br />
* '''className''' is the second element in WM_CLASS(STRING)<br />
* '''title''' is WM_NAME(STRING)<br />
<br />
For example, in <code> WM_CLASS(STRING) = "emacs", "Emacs" </code> -- "emacs" is resource (appName), "Emacs" is className.<br />
<br />
(Applications may change the title after window creation, before xprop sees it. If possible, use resource or class in such cases.) stringProperty "WM_WINDOW_ROLE" can also be useful.<br />
<br />
Sample output might look like:<br />
<br />
<pre>_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0<br />
XdndAware(ATOM) = BITMAP<br />
WM_STATE(WM_STATE):<br />
window state: Normal<br />
icon window: 0x0<br />
WM_HINTS(WM_HINTS):<br />
Client accepts input or input focus: True<br />
Initial state is Normal State.<br />
window id # of group leader: 0xf600001<br />
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 257949716<br />
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL<br />
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0xf600013<br />
WM_CLIENT_LEADER(WINDOW): window id # 0xf600001<br />
_NET_WM_PID(CARDINAL) = 476661<br />
WM_LOCALE_NAME(STRING) = "en_US.utf8"<br />
WM_CLIENT_MACHINE(STRING) = "localhost"<br />
WM_NORMAL_HINTS(WM_SIZE_HINTS):<br />
program specified minimum size: 32 by 34<br />
program specified resize increment: 8 by 17<br />
program specified base size: 16 by 0<br />
window gravity: NorthWest<br />
WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST<br />
WM_CLASS(STRING) = "emacs", "Emacs"<br />
WM_ICON_NAME(STRING) = "emacs@craft"<br />
_NET_WM_ICON_NAME(UTF8_STRING) = 0x45, 0x4d, 0x41, 0x43, 0x53<br />
WM_NAME(STRING) = "EMACS"<br />
_NET_WM_NAME(UTF8_STRING) = 0x45, 0x4d, 0x41, 0x43, 0x53<br />
</pre><br />
<br />
Note: the last several lines contain useful information like the CLASS and<br />
hinting information.<br />
<br />
==== What about other properties, such as WM_WINDOW_ROLE? ====<br />
Use <code>stringProperty</code> to extract string information, for<br />
example:<br />
<br />
<pre><br />
stringProperty "WM_WINDOW_ROLE" =? "presentationWidget" --> doFloat<br />
</pre><br />
<br />
For non-string properties, try [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ManageHelpers.html XMonad.Hooks.ManageHelpers].<br />
<br />
Consult the [http://xmonad.org/xmonad-docs/xmonad/XMonad-ManageHook.html XMonad.ManageHook] documentation for more information.<br />
<br />
==== A handy script to print out window information ====<br />
<br />
This script will print window information (if available) in formats usable within <tt>xmonad.hs</tt>. It is also included in the $src/XMonadContrib/scripts directory with<br />
darcs XMonadContrib (>= 0.10).<br />
<br />
#! /bin/sh<br />
exec xprop -notype \<br />
-f WM_NAME 8s ':\n title =\? $0\n' \<br />
-f WM_CLASS 8s ':\n appName =\? $0\n className =\? $1\n' \<br />
-f WM_WINDOW_ROLE 8s ':\n stringProperty "WM_WINDOW_ROLE" =\? $0\n' \<br />
WM_NAME WM_CLASS WM_WINDOW_ROLE \<br />
${1+"$@"}<br />
<br />
It works like <tt>xprop</tt>: by default you click on a window with the crosshairs, or you can specify windows using the <tt>-id</tt> or <tt>-name</tt> options. (The <tt>-root</tt> and <tt>-font</tt> selectors could be used, but are less than useful. Also, <tt>-frame</tt> is unlikely to do anything useful.)<br />
<br />
See [[Xmonad/General_xmonad.hs_config_tips#Matching_specific_windows_by_setting_the_resource_name_or_class|Matching specific windows by setting the resource name or class]] for how you can change what programs use for some of these strings.<br />
<br />
=== What is the xK_ value for this key? ===<br />
Pressing the key of interest while focusing a xev window gives useful information.<br />
To limit xev's output use something like:<br />
<br />
<code>xev | sed -ne '/^KeyPress/,/^$/p'</code><br />
<br />
A complete list can be found at [[Xmonad/Key_codes|XMonad key symbols]].<br />
<br />
=== How can I send a key sequence to a window? ===<br />
<br />
This can be useful when some application uses a hotkey that you<br />
want to use in XMonad, yet be able to send the application window the<br />
hotkey when needed.<br />
<br />
A solution is to use [http://www.semicomplete.com/projects/xdotool/ xdotool], <br />
which can (among other nifty things), send a fake keypress to the<br />
currently focused window. So, for instance, you can use the following<br />
keybinding to send Alt+L to the focused window by pressing Ctrl+Alt+L:<br />
<br />
, ((mod1Mask|controlMask, xK_l), spawn "xdotool key alt+l")<br />
<br />
[http://www.semicomplete.com/projects/xdotool/ xdotool] can also paste<br />
a line of ASCII text into the focused window. For instance, the<br />
following keybinding will insert the email address email@example.org<br />
each time the key Ctrl+Alt+e is pressed:<br />
<br />
, ((mod1Mask|controlMask, xK_e), spawn "xdotool text 'email@example.org'")<br />
<br />
The <code>XMonad.Util.Paste</code> module (in >= xmonad-contrib-0.9) defines functions to to the same with<br />
pure Haskell code.<br />
<br />
=== I don't use a statusbar, but I'd like to have layout displayed for some time when it changes ===<br />
<br />
Let's assume you have <hask>import qualified XMonad.StackSet as W</hask> in xmonad.hs.<br />
<br />
Add the following declaration somewhere in the toplevel:<br />
<haskell>curLayout :: X String<br />
curLayout = gets windowset >>= return . description . W.layout . W.workspace . W.current</haskell><br />
<br />
Then add the keybinding:<br />
<haskell><br />
, ((mod1Mask, xK_a ), sendMessage NextLayout >> (curLayout >>= \d->spawn $"xmessage "++d))<br />
</haskell><br />
<br />
You might want to change xmessage to the more friendly program, such as osd_cat, qt-dialog or dzen2.<br />
<br />
Another option is to use<br />
[http://www.xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-ShowWName.html Layout.ShowWName] <br />
which has some user configurable options such as font, color and fade timings.<br />
<br />
More flexible way is to use <code>dynamicLogString</code> from <code>XMonad.Hooks.DynamicLog</code> (was added after 0.6 release), which can also display current workspace, window name, layout, and even arbitrary <hask>[X (Maybe String)]</hask>, and format them nicely, printing them to xmonad's stdout.<br />
<br />
===How can I make xmonad use UTF8?===<br />
<br />
TODO: is this still accurate? Doesn't xmonad-0.8 and greater always use UTF8 with no extra imports or configuration changes?<br />
<br />
Due to extensions like [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html DynamicLog], xmonad is capable of text outputting which is not by default but can be encoded in UTF8. Therefore, if you want to output non-ASCII characters, you can take advantage of the [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string System.IO.UTF8] module.<br />
<br />
For example using DynamicLog you can define its output [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#v%3AppOutput ppOutput] like his:<br />
<haskell><br />
import qualified System.IO.UTF8<br />
-- lots of other stuff<br />
ppLog = defaultPP<br />
{ ppOutput = \s -> do<br />
h <- openFile "/home/$USER/.xmonad/xmonad.log" WriteMode<br />
System.IO.UTF8.hPutStrLn h s<br />
hClose h<br />
}<br />
</haskell><br />
<br />
As it may not be ideal to reopen the file before every writing, you can just place the code somewhere else. See ray's config in xmonad's [[Xmonad/Config_archive|config archive]].<br />
<br />
===How do I use compositing with xmonad?===<br />
<br />
Xmonad has the ability to use some compositing features yet still be actually useable ;-). For example, some really nice transparency can be used with a composite aware app like urxvt and xcompmgr. <br />
<br />
First enable compositing in your X server configuration by including the following in your xorg.conf<br />
<br />
<pre><br />
Section "Extensions"<br />
Option "Composite" "enable"<br />
EndSection<br />
</pre><br />
<br />
restart the X server and confirm it's working with xdpyinfo | grep Composite. If it returns Composite, then good...<br />
<br />
Include this in ~/.Xdefaults<br />
<br />
<pre><br />
URxvt.depth: 32<br />
URxvt*background: rgba:0000/0000/0000/cccc<br />
</pre><br />
<br />
this specifies that urxvt uses 32 bit colors and uses a transparent black background. The four c's specify the amount of alpha with ffff being full black and 0000 being fully transparent. You can also use the fading and blurRadius resources to give some nice effects in the transparency. see man urxvt.<br />
<br />
finally you need to fire up xcompgr so that this will all actually work. probably you'll want to include it in your ~/.xinitrc or ~/.xsession file:<br />
<br />
<pre><br />
xcompmgr -c &<br />
</pre><br />
<br />
the -c option provides a soft shadow around your windows. There are many options, see man xcompmgr. <br />
<br />
For an example with screenshots see andrewsw's config in the [[Xmonad/Config_archive|config archive]].<br />
<br />
On newer versions of XMonad, see also '''XMonad.Hooks.FadeInactive''' documentation.<br />
<br />
=== How do I find a function which does ...? ===<br />
<br />
[http://holumbus.fh-wedel.de/hayoo/hayoo.html Hayoo!] API search can be used to find existing functions within XMonad and XMonadContrib which do useful things. For example, the search string<br />
(next AND screen) package:xmonad<br />
will find all existing functions which mention moving to the next Xinerama screen.<br />
<br />
==Troubleshooting==<br />
<br />
===Multi head or xinerama troubles===<br />
====xmonad does not detect my multi-head setup====<br />
<br />
To diagnose the problem, execute the following on the command line:<br />
<br />
ghc -e Graphics.X11.Xinerama.compiledWithXinerama<br />
<br />
If the output is True, skip to the getScreenInfo test below. If the output is False, your Haskell X11 library was not built against Xinerama. This is true of old Debian and Ubuntu packages, and may also occur if you built from source.<br />
<br />
First, be sure that the Xinerama development headers are installed (libxinerama-dev in Debian and Ubuntu).<br />
<br />
Next, check the configure output for the Haskell X11 library for the following lines (If using cabal: cabal install X11 -v --reinstall):<br />
<br />
checking X11/extensions/Xinerama.h usability... yes<br />
checking X11/extensions/Xinerama.h presence... yes<br />
checking for X11/extensions/Xinerama.h... yes<br />
<br />
If any of these lines end in "no", the Xinerama headers are not installed. If the lines end in "yes", execute:<br />
<br />
runghc Setup clean<br />
runghc Setup configure --user --prefix=$HOME<br />
runghc Setup build<br />
runghc Setup install<br />
<br />
In the X11, xmonad and xmonad-contrib source directories. Try the compiledWithXinerama diagnostic again, this time it should return True. As always, execute "xmonad --recompile" when reinstalling any part of xmonad.<br />
<br />
If compiledWithXinerama is True and multi-head still doesn't work, execute "xmonad --recompile" and press mod-q. If the problem persists, execute this command:<br />
<br />
ghc -e "Graphics.X11.openDisplay [] >>= Graphics.X11.Xinerama.getScreenInfo"<br />
<br />
Here is a sample output from a system with two 1280 by 1024 monitors, oriented side by side:<br />
<br />
[Rectangle {rect_x = 0, rect_y = 0, rect_width = 1280, rect_height = 1024}, Rectangle {rect_x = 1280, rect_y = 0, rect_width = 1280, rect_height = 1024}]<br />
<br />
Check to see whether there is a Rectangle corresponding to each of your screens. If there is not, and the compiledWithXinerama diagnostic returns True, there may be a problem with your X server configuration. The most common one is having your monitors set to ''clone'' one another. See 'man xrandr', or, if using the proprietary nvidia drivers, 'nvidia-settings' to see how reconfigure them.<br />
<br />
Also, there can be two versions of the X11 haskell library installed, one of them built with Xinerama, and other without it. If XMonad is using the one built with Xinerama, and the output of the commands use the version without it, all these tests will work but these problems will persist. Check the output of ghc-pkg to see if there is more than one version of X11 installed.<br />
<br />
====Missing X11 headers====<br />
<br />
Your build will fail if you've not installed the X11 C library headers<br />
at some point. ./configure for the Haskell X11 library will fail. To<br />
install the X11 C libs:<br />
<br />
* debian<br />
<br />
apt-get install libx11-dev<br />
<br />
====X11 fails to find libX11 or libXinerama====<br />
<br />
Cabal has difficulty locating library directories on some<br />
platforms (such as the Mac or RHEL4). First, locate the<br />
directory that contains libX11.so (libX11.dylib on Mac OS<br />
X). Add the following line to the .cabal file for the<br />
package:<br />
<br />
extra-lib-dirs: /your/path/here/<br />
<br />
For example, on a 64 bit machine you might need to add:<br />
<br />
extra-lib-dirs: /usr/X11R6/lib/lib64<br />
<br />
You can also add the paths to your .buildinfo file, or set the<br />
LD_LIBRARY_PATH environment variable.<br />
<br />
====Something is weird with multi head windows or workspaces (desktops)====<br />
See [[#Multi head and workspaces (desktops)|Configuration: Multi head and workspaces]]<br />
<br />
===X Error of failed request: BadAccess (attempt to access private resource denied)===<br />
This message seen at xmonad's stdout when starting xmonad means that another window manager is already running. If the other WM was started from a DE, you can use [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Util-Replace.html Util.Replace] to have xmonad ask the other WM to exit before starting up. Note: If exiting your previously running wm would lead to your X session ending, then this method won't work. <br />
<br />
Otherwise refer to the appropriate page for starting xmonad instead of your other WM ([[Xmonad/Using xmonad in Gnome|Gnome]], [[Xmonad/Using xmonad in KDE|KDE]]).<br />
<br />
===mod-q doesn't work===<br />
====Upgraded GHC and now xmonad xmonad-contrib etc are not found====<br />
When you change ghc versions you need to rebuild or reinstall haskell libraries to make sure they are compatible and registered with the new ghc. Often your distro packagers will try to make this as automatic as possible, by making it just happen. Or at least they will make it easier, e.g. gentoo's ghc-updater and haskell-updater. (This isn't just a Haskell/ghc issue; it's true for other languages, too: c.f. python-updater scripts, distro policies regarding gcc and glibc changes.)<br />
<br />
==== Changes to the config file ignored or 'xmonad not found' when starting X ====<br />
<br />
Both ghc and xmonad must be in your display manager init's $PATH when starting X and xmonad for reconfiguration by mod-q. Make sure the environment from which you start xmonad has the appropriate settings.<br />
<br />
When changing the xmonad.hs and restarting with mod-q, xmonad will attempt to exec the xmonad binary. This means it must be in your $PATH environment variable, or the exec will fail silently and the old xmonad instance keeps running.<br />
<br />
With xmonad 0.5 and later, mod-q will also call ghc on your ~/.xmonad/xmonad.hs file, and will continue with defaults if ghc is not found.<br />
<br />
Additionally, if you change and reinstall the haskell-X11 or XMonadContrib library, changes to that package will not be noticed by xmonad's recompilation<br />
checker, so xmonad.hs won't be recompiled. ''(needs confirmation: is this true?)'' To fix this:<br />
<br />
xmonad --recompile<br />
<br />
after reinstalling the contrib library.<br />
<br />
===Tabbed or other decorated layouts not shown===<br />
Both xmobar and xmonad's default <br />
[http://hackage.haskell.org/packages/archive/xmonad-contrib/latest/doc/html/XMonad-Layout-Tabbed.html Theme] <br />
use the <code>-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*</code> font by default. This is<br />
possibly the most commonly installed font in the *nix world, but if it's not installed,<br />
or core fonts aren't working for some reason, you'll have problems. Without the font<br />
you have set in your Theme....<br />
<br />
tabs and other decorated layouts will simply not draw. There should be font related errors<br />
in .xsession-errors or wherever your display manager directs stderr to help confirm that<br />
this is the cause of missing decorations. xmobar will spit out a cryptic error message<br />
and refuse to run.<br />
<br />
Check with xfontsel that you have the fixed 10 font if you want to use the defaults.<br />
For xft, check that your xmonad and xmobar were compiled with xft support. (They are<br />
by default on most distros) Then customize your theme by using something like the<br />
following in your layoutHook<br />
<haskell><br />
myTabbed = tabbed shrinkText defaultTheme {<br />
fontName = "xft:terminus:size=12" -- choose an installed font<br />
-- more theme customizations<br />
}<br />
<br />
main = do<br />
-- skipped<br />
, layoutHook = avoidStruts $ myTabbed ||| layoutHook defaultConfig<br />
} <br />
</haskell> <br />
<br />
===DE panels pagers or EwmhDesktops are broken (just upgraded to >0.8)===<br />
Starting with 0.9, <br />
EwmhDesktops users ''must'' [http://code.haskell.org/XMonadContrib/XMonad/Hooks/EwmhDesktops.hs change configuration] by removing the obsolete ewmhDesktopsLayout from layoutHook, (it no longer exists), and updating to the current ewmh support which still includes a logHook, but in place of the old layout modifier, uses a startupHook and handleEventHook (see ff.).''(No need to change config if using ewmh via Config.Desktop, Config.Gnome, etc. Your config will automatically be updated to use current ewmh support.)<br />
<br />
Users of defaultConfig that explicitly include EwmhDesktops hooks and the ewmhDesktopsLayout modifier should remove them and instead use the new <hask>ewmh</hask> function which adds EWMH support to <hask>defaultConfig</hask> all at once. You should keep avoidStruts and manageDocks if you're using them.<br />
<br />
The 0.9 way to use EwmhDesktops rather than a desktop config is:<br />
<haskell><br />
import XMonad<br />
import XMonad.Hooks.EwmhDesktops<br />
<br />
main = xmonad $ ewmh defaultConfig {<br />
-- normal customizations<br />
}<br />
</haskell><br />
<br />
===defaultGaps doesn't work any more! (just upgraded to >0.7)===<br />
See [[#Make space for a panel dock or tray | Make space for a panel]] section: use XMonad.Hooks.ManageDocks avoidStruts for this instead of Gaps, or import XMonad.Layout.Gaps.<br />
<br />
===Showing fractions of lines in gvim, urxvt,etc.===<br />
<br />
This is due to certain layouts doesn't care about so called size hints<br />
(resize increments) specifically the WM_NORMAL_HINTS(WM_SIZE_HINTS) (use<br />
xprop to see it). This, combined with certain programs, like gvim, which<br />
doesn't check if it gets enough size to render the last line and uses it anyway<br />
render this annoying behaviour. Aside from patching the offending program, you can:<br />
<br />
<ol><br />
<li>Use a layout which uses these size hints like Hinted Grid, or HintedTile</li><br />
<li>Use the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-LayoutHints.html layoutHints] modifier on any layout</li><br />
<li>Workaround in .vimrc. These lines in your .vimrc lets you change the number of lines with F4/Shift-F4:</li><br />
<pre><br />
map <F4> :let &lines=&lines-1<CR><br />
map &lt;S-F4&gt; :let &lines=&lines+1<CR><br />
</pre><br />
<li>Change the color of default GTK background (white lines), to match gvim background</li><br />
<pre><br />
style "vimfix" { bg[NORMAL] = "#000000" }<br />
widget "vim-main-window.*GtkForm" style "vimfix"<br />
</pre><br />
</ol><br />
<br />
===Emacs mini-buffer starts at wrong size===<br />
ontoillogical says: Most people turn off menus and toolbars and adjust fonts in their .emacs. That's what breaks emacs' display in tiling WMs. To get emacs to look correctly, move all of the stuff that affects how emacs draws a frame to .Xdefaults/.Xresources<br />
<br />
For reference here is the relevant section of mine:<br />
<br />
Emacs.font: DejaVu Sans Mono-12<br />
Emacs.fontBackend: xft<br />
Emacs.menuBar: off<br />
Emacs.toolBar: -1<br />
Emacs.verticalScrollBars: off<br />
<br />
If you're having emacs sizing problems setting these in .Xdefaults is still worth a try even if you don't have any custom .emacs settings.<br />
<br />
===Losing text when resizing xterms===<br />
<br />
Being a dynamic tiling window manager, xmonad, like ion or dwm, makes heavy use of resizing. Clients such as xterm, might not take well to resizing and the window might require a refresh (Ctrl-L). To minimize this, several users recommend urxvt (rxvt-unicode), which handles resizing much better.<br />
<br />
=== I just resized my terminal, but the terminal app didn't resize. ===<br />
This is a SIGWINCH bug in the Linux kernel, believe it or not, in the 2.6.26 series. Details here: http://groups.google.com/group/fa.linux.kernel/browse_thread/thread/8044876def45c0b0/4b7f4cd87feafe5e?show_docid=4b7f4cd87feafe5e.<br />
<br />
The simplest solution is to up/downgrade to a kernel version without this bug.<br />
<br />
===XMonad is frozen!===<br />
<br />
==== XMonad stops but the current window still responds to keys ====<br />
<br />
Usually this is because a dynamicLog is writing to a pipe handle that's not being read. For example the xmonad.hs writes to some status bar in the logHook, but the status bar is not installed, not in $PATH, not set up to read its stdin, or just plain not running. Eventually the pipe fills up and blocks and xmonad waits for it to be read before continuing.<br />
<br />
To cat the full pipe and free up xmonad, find xmonad's pid via pgrep or htop, etc. let's say it's 1001, then <code>ls -l /proc/1001/fd/</code> and look for the largest numbered pipe. Let's use 4. Then <code>cat /proc/1001/fd/4</code> to unblock xmonad so you can fix your xmonad.hs and xmobarrc to work correctly. (If catting that pipe doesn't spew out a bunch of stuff and unfreeze things, try the others listed.)<br />
<br />
With the post 0.9 <hask>=<< xmobar</hask> and <hask>statusBar</hask> modifiers it isn't obvious that xmonad is writing to a pipe. If you don't want xmonad info shown in your<br />
status bar, you will probably be better off launching it by other means such as .xinitrc. You can also customize your PP's ppOutput field to use the default <hask>hPutStrLn</hask> to write to stdout, or change it to <hask>\s -> return ()</hask> to do nothing at all.<br />
<br />
<em>With xmobar</em>, if your logHook is writing to its stdin via <hask>ppOutput = hPutStrLn foo</hask>, make sure the .xmobarrc <hask>commands</hask> include a <hask>Run StdinReader</hask> line, and the <hask>template</hask> includes <hask>%StdinReader%</hask>.<br />
<br />
For examples of an .xmobarrc with working StdinReader, see this [https://wiki.archlinux.org/index.php/Xmonad#Using_xmobar_with_xmonad arch linux help page] or [[Xmonad/Config_archive/John_Goerzen%27s_Configuration|John Goerzen's xmonad config tutorial]].<br />
<br />
See also [http://code.google.com/p/xmonad/issues/detail?id=91 this issue] on the xmonad bug tracker.<br />
<br />
==== XMonad stops responding to keys (usually due to unclutter) ====<br />
<br />
The number one cause for this is the 'unclutter' program, which can fool<br />
some clients into thinking they've lost the pointer, when in fact they have<br />
not. See the '-noevents' flag to unclutter.<br />
Or use [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-Warp.html XMonad.Actions.Warp] or [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-UpdatePointer.html XMonad.Actions.UpdatePointer] xmonad-contrib extension instead.<br />
<br />
==== An app seems to have frozen and xmonad stops responding to keys ====<br />
<br />
Often you can get X to behave again by running 'xclock -display :0' on the appropriate display via ssh or from a virtual terminal. If that's not enough kill suspect apps similarly.<br />
<br />
There is also an option in (pre evdev versions of) xorg.conf which enables the key combination '''Ctrl+Alt+Keypad-Divide''' to break active keyboard and mouse grabs. <br />
<br />
This may allow xmonad to continue normally in such cases. To enable this key combination, add the following line to your xorg.conf in the Section ''Server Flags'' then restart X:<br />
<br />
Option "AllowDeactivateGrabs" "on"<br />
<br />
=== Problems with Java applications, Applet java console ===<br />
<br />
The Java gui toolkit has a hardcoded list of so-called "non-reparenting"<br />
window managers. xmonad is not on this list (nor are many of the newer window<br />
managers). Attempts to run Java applications may result in `grey blobs' where<br />
windows should be, as the Java gui code gets confused.<br />
<br />
The following workarounds also fix an issue with Java gui applications where menus are not "selectable". (Clicking on the menu item opens the dropdown list of options but you can't select one, or the menu disappears when you are looking at it.)<br />
<br />
If you are still having focus problems, even after implementing the workarounds, see also<br />
[http://code.google.com/p/xmonad/issues/detail?id=177 issue 177].<br />
<br />
====Preferred Method====<br />
If you are using openjdk6 >= 1.6.1, the cleanest way to work around the hardcoded list is to warn the vm that xmonad is non-reparenting by exporting the appropriate environment variable:<br />
<br />
_JAVA_AWT_WM_NONREPARENTING=1<br />
<br />
Using JDK 7 seems to work well, too, see below.<br />
<br />
====Using SetWMName====<br />
Otherwise, you can lie to Java about what window manager you are using, by having the [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-SetWMName.html SetWMName] extension convince Java that xmonad is '''"LG3D"'''. Normally you would use this in<br />
startup hook, like this:<br />
<br />
<haskell><br />
-- etc<br />
import XMonad.Hooks.SetWMName<br />
<br />
main = do<br />
xmonad $ defaultConfig<br />
{ modMask = mod4Mask<br />
, startupHook = setWMName "LG3D"<br />
-- other customizations<br />
}<br />
</haskell><br />
'''However''', modules using Hooks.EwmhDesktops, such as Config.Gnome, Config.Desktops, etc. also set WM Name as part of supporting Extended Window Manager Hints. Combining EWMH support with the "LG3D" workaround takes special attention to modifying the appropriate hook for your xmonad version:<br />
<br />
'''Starting with xmonad-0.9'''. the window manager name is set once in EWMH '''''startupHook''''' after each mod-q, along with other EWMH initialization, but after that can be changed and not overwritten till the next mod-q. See below for example startupHooks combining both startupHooks.<br />
<br />
'''In xmonad versions 0.7 and 0.8''' the EWMH configs setWMName to "xmonad" on each '''''logHook''''' event, so to use "LG3D" instead, it's necessary to either<br />
* patch the XMonad.Hooks.EwmhDesktops source and rebuild xmonad-contrib<br />
OR<br />
* use the version 0.8.* hack shown below to repeatedly setWMName "LG3D" after the ewmh logHook runs.<br />
<br />
==== Using SetWMName with EwmhDesktops ====<br />
<br />
For '''xmonad-0.9 0.9.1 or darcs''':<br />
<br />
Add ewmhDesktopsStartup, (or 'startupHook gnomeConfig', etc.) to '''''startupHook''''' ''before'' setWMName.<br />
<br />
Defining the EWMH hooks yourself:<br />
<haskell><br />
-- etc<br />
import XMonad.Hooks.EwmhDesktops<br />
import XMonad.Hooks.SetWMName<br />
<br />
main = xmonad defaultConfig<br />
{ -- skipped<br />
, startupHook = ewmhDesktopsStartup >> setWMName "LG3D"<br />
}<br />
</haskell><br />
<br />
Using a desktop config as your base:<br />
<haskell><br />
xmonad desktopConfig<br />
{ -- skipped<br />
, startupHook = startupHook desktopConfig >> setWMName "LG3D"<br />
}<br />
</haskell><br />
<br />
If instead you're using the ewmh config modifier to add EWMH support, then define your config at top-level to allow over-riding the startupHook definition with your own version:<br />
<haskell><br />
-- etc<br />
import XMonad.Hooks.EwmhDesktops<br />
import XMonad.Hooks.SetWMName<br />
<br />
-- define an EWMH base config to use later in main<br />
conf = ewmh defaultConfig<br />
{ manageHook = myManageHooks <+> manageDocks <+> manageHook defaultConfig<br />
, layoutHook = avoidStruts $ myLayout ||| layoutHook defaultConfig<br />
, logHook = dynamicLogWithPP xmobarPP<br />
{ ppOutput = hPutStrLn xmproc<br />
, ppLayout = const ""<br />
, ppTitle = xmobarColor "green" "" . shorten 80<br />
}<br />
}<br />
<br />
-- Override the WM Name setting for the "LG3D" workaround<br />
-- but still use the rest of the EWMH base config you just<br />
-- defined, including its startupHook ewmh initialization<br />
<br />
main = do<br />
xmproc <- spawnPipe "xmobar"<br />
xmonad conf<br />
{ startupHook = startupHook conf >> setWMName "LG3D"<br />
}<br />
</haskell><br />
<br />
For '''xmonad-0.8.*''' :<br />
<haskell><br />
-- etc<br />
import XMonad.Hooks.EwmhDesktops<br />
import XMonad.Hooks.ManageDocks<br />
import XMonad.Hooks.SetWMName<br />
<br />
main = do<br />
xmproc <- spawnPipe "xmobar"<br />
xmonad $ defaultConfig<br />
{ manageHook = myManageHooks <+> manageDocks <+> manageHook defaultConfig<br />
, layoutHook = avoidStruts $ ewmhDesktopsLayout $ myLayout ||| layoutHook defaultConfig<br />
-- NOTE: no '$' is used between dynamicLogWithPP and xmobarPP<br />
, logHook = dynamicLogWithPP xmobarPP<br />
{ ppOutput = hPutStrLn xmproc<br />
, ppLayout = const ""<br />
, ppTitle = xmobarColor "green" "" . shorten 80<br />
}<br />
>> ewmhDesktopsLogHook<br />
>> setWMName "LG3D"<br />
<br />
---- or with a desktop config, e.g.<br />
-- , logHook = logHook gnomeConfig >> setWMName "LG3D"<br />
}<br />
</haskell><br />
<br />
With xmonad-0.9 or greater there is no need to spam the X server with setWMName in logHook, see above for how to modify startupHook instead.<br />
<br />
==== Changing AWT Toolkit ====<br />
Another option is to use an AWT toolkit that is more window manager agnostic, (Some report that this causes keyboard to fail in some java applications. It also doesn't seem to work as widely or reliably as setWMName or other preferred methods above.) If you want to try it, set the environment variable:<br />
<br />
AWT_TOOLKIT=MToolkit<br />
<br />
This seems to fix some versions of:<br />
<br />
* MATLAB<br />
* cgoban3<br />
* Netbeans<br />
* processing [http://processing.org]<br />
<br />
Even if you don't use Bash, you can often set environmental variables by putting them in .profile and logging back in:<br />
<br />
export AWT_TOOLKIT=MToolkit<br />
<br />
Using the free blackdown java runtime also seems to work correctly to fix this issue.<br />
<br />
==== Use JDK 7 ====<br />
* Using JDK 7 also seems to work well.<br />
<br />
Anthony Brown writes: <blockquote>I just downloaded and early binary release of JDK 7 and it looks like the new Java version behaves properly ... I tried using some Gui apps that gave me the infamous grey windows with Java6 (or Java5 without setting AWT_TOOLKIT=MToolkit) and so far no problems occured.</blockquote><br />
<br />
Gunnar Ahlberg #xmonad: <blockquote>JDK 7 solved problems remaining even when using setWMName "LG3D" in logHook.</blockquote><br />
<br />
==== Persuade a java application to use a specific java runtime (JRE) ====<br />
<br />
Sometimes it turns out that a program works with a specific JRE version, but not with another. Commercial programs tend to ship with their own JRE, so you may even notice that one program works while another doesn't. (For example, I've had a setup where Maple had problems while Matlab behaved well.) A java symlink in the right place can do wonders here. See [https://bugs.launchpad.net/xorg-server/+bug/185311 this Ubuntu bug report] for a number of examples.<br />
<br />
===XMonad doesn't save my layouts and windows===<br />
<br />
xmonad will remember your workspace layouts during dynamic restart<br />
(mod-q), but not when quitting X altogether. Note that this means <br />
if you add or remove layouts to the config.hs file, the changes won't be<br />
noticed during a hot-restart (the state from the previous session will<br />
be used).<br />
<br />
You can reinitialise the xmonad state dynamically with mod-shift-space.<br />
<br />
===Some keys not working===<br />
If you've an unusual keyboard, X may not know precisely which keys<br />
you've bound xmonad actions to. An example is when you use a<br />
French keyboard layout. You may need to set your own mod key, or use<br />
different key bindings in xmonad.hs. See the xmonad.org docs on configuring and customizing for advice on rebinding keys. Also currently xmonad only handles the first of duplicate key symbols bound, so if you have for example multiple xK_Backspace keys not all will be bound. There are patches available on the xmonad mailing list (or darcswatch) to change this.<br />
<br />
====Media keys====<br />
XMonad.Util.EZConfig additionalKeysP or Graphics.X11.ExtraTypes are the best way to bind the XF86 family of special keys. Note that some special laptop keys are handled by acpi and may show up as button events instead, or even bypass X completely.<br />
<br />
====French keyboard workspace switching====<br />
See XMonad.Config.Azerty for an azertyConfig to use in place of defaultConfig. This will adjust keybindings for the azerty layout, fixing workspaces switching, etc.<br />
<br />
====Numeric keypad keys like xK_KP_2 not working====<br />
Bind to the non-numeric versions of these keys. They work regardless of NumLock status. To avoid conflicts with other apps you probably want to use them with modifiers. Here is an example of using them to navigate workspaces in the usual mod-N mod-shift-N way, but on the key pad:<br />
<br />
<haskell><br />
myWorkspaces = ["1","2","3","4","5","6","7","8","9","0"]<br />
<br />
modm = mod4Mask -- win key for mod<br />
<br />
myKeys = -- use with EZConfig.additionalKeys or edit to match your key binding method<br />
[<br />
-- more custom keybindings<br />
]<br />
++<br />
[((m .|. modm, k), windows $ f i)<br />
| (i, k) <- zip myWorkspaces numPadKeys<br />
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]<br />
]<br />
<br />
-- Non-numeric num pad keys, sorted by number <br />
numPadKeys = [ xK_KP_End, xK_KP_Down, xK_KP_Page_Down -- 1, 2, 3<br />
, xK_KP_Left, xK_KP_Begin, xK_KP_Right -- 4, 5, 6<br />
, xK_KP_Home, xK_KP_Up, xK_KP_Page_Up -- 7, 8, 9<br />
, xK_KP_Insert] -- 0 <br />
</haskell><br />
<br />
====Keybindings dont work with rdesktop====<br />
Try running with the "-K" (keep window manager key bindings) switch. For example, <code>rdesktop -K -f 666.666.666.666</code> then press Ctrl-Alt-Enter, or simply <code>rdesktop -K 666.666.666.666</code><br />
<br />
===Copy and Paste on the Mac===<br />
<br />
When using X11 for Mac OS X, and you switch from the quartz WM to<br />
xmonad, you can lose copy/paste functionality between X windows and<br />
normal Mac apps. To fix this, and restore copy and paste, add<br />
<br />
quartz-wm --only-proxy &<br />
<br />
in your .xinitrc above the line that runs xmonad. It will capture and<br />
syncronize copy/paste events in both environments. More specifically,<br />
it mirrors OS X copy actions into both PRIMARY and CLIPBOARD, but only<br />
CLIPBOARD into OS X paste.<br />
<br />
===OpenOffice looks bad===<br />
<br />
OpenOffice won't use (strangely) the GTK look, unless the following<br />
environment variable is set:<br />
<br />
OOO_FORCE_DESKTOP=gnome<br />
<br />
Use this if you don't like the default look of OpenOffice in xmonad.<br />
<br />
=== Help! xmonad just segfaulted ===<br />
<br />
Due to this bug in GHC's recompilation checker,<br />
<br />
http://hackage.haskell.org/trac/ghc/ticket/1372<br />
<br />
if you updated a previously built xmonad, or XMonadContrib, when a<br />
dependent library has changed in the meantime, GHC will happily go ahead<br />
and link your libraries together, into a broken binary. This will at<br />
best produce a linker error, and at worst, a version of xmonad that will<br />
segfault. <br />
<br />
The rule is: when rebuilding, for example, XMonadContrib, always clean<br />
first if any library it depends on has changed.<br />
<br />
runhaskell Setup.lhs clean<br />
<br />
You may also want to make sure your config gets rebuilt:<br />
<br />
xmonad --recompile<br />
<br />
Another possibility is your xmonad was compiled against a very old<br />
version of the haskell-x11 library. Use haskell-X11-1.4.2 or newer.<br />
This version incorporates a couple of WM_HINTS related segfault bug<br />
fixes.<br />
<br />
=== Cabal: Executable stanza starting with field 'flag small_base description' ===<br />
<br />
When using ghc 6.6, or old versions of Cabal, you may get errors when configuring:<br />
<br />
*** Exception: getSection got a line without a '{'. Consider this a bug.<br />
<br />
These are all symptoms of trying to compile xmonad with an old version<br />
of cabal.<br />
<br />
The darcs version after xmonad 0.4 switched to requiring Cabal 1.2 to<br />
build xmonad. You '''must''' have Cabal 1.2 or newer to build xmonad<br />
older than 0.4. It will work fine with ghc 6.6.1, and you do not need to<br />
updated ghc. This will also not break older packages. Get cabal from Hackage:<br />
<br />
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Cabal<br />
<br />
Build and install as usual, then rebuild xmonad.<br />
<br />
To build Cabal with ghc 6.6.1 you will also need the filepath library,<br />
which is also (of course) available from hackage:<br />
<br />
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/filepath<br />
<br />
=== configure: error: cannot run C compiled programs. ===<br />
<br />
This typically means that you have /tmp mounted with noexec. To use another directory, make an alias that temporarily changes $TMPDIR, like<br />
<br />
alias cabal="TMPDIR=[insert directory here, eg ~/.cabal/build but make sure the directory exists] cabal"<br />
<br />
=== A manage hook is having no effect ===<br />
<br />
If a manage hook that checks an attribute of a window(e.g. resource =? "foo"<br />
--> bar) doesn't work even though the property is the same as reported by<br />
xprop, it can be caused by a program setting the corresponding property after<br />
the window has been created. To debug whether or not the term on the right<br />
hand side is at fault, it is useful to log which resource (or other property)<br />
xmonad sees:<br />
<br />
<haskell><br />
(resource >>= io . appendFile "/home/<youruser>/xmonad_debug" >> idHook)<br />
</haskell><br />
<br />
If opening the desired window causes xmonad to produce a log entry with the<br />
resource you were interested in, it means that the term on the right-hand side<br />
of --> is not working.<br />
<br />
[[Category:XMonad]]</div>Marcothttps://wiki.haskell.org/index.php?title=Talk:No_export_lists&diff=39744Talk:No export lists2011-05-04T11:53:52Z<p>Marcot: New page: I like your proposal, but I think it would be better to mark with * names that should not be exported, instead of the names that should.</p>
<hr />
<div>I like your proposal, but I think it would be better to mark with * names that should not be exported, instead of the names that should.</div>Marcothttps://wiki.haskell.org/index.php?title=Num_instance_for_functions&diff=39743Num instance for functions2011-05-04T11:53:02Z<p>Marcot: BASIC blog post</p>
<hr />
<div>Some people have argued, that <hask>Num</hask> instances of <hask>(->)</hask> would be nice in order<br />
to add functions nicely, say for<br />
<haskell>f, g :: Num a => b -> a</haskell><br />
you would define<br />
<haskell>(f+g) x = f x + g x</haskell><br />
<br />
With an according definition of <hask>fromInteger</hask><br />
<haskell>fromInteger = const</haskell><br />
numeric literals would also denote constant functions. This allows<br />
<haskell>f+2 == \x -> f x + 2</haskell>.<br />
<br />
Even nicer, the mathematically established notation of omitting the<br />
multiplication dot<br />
<haskell>2(x+y) :: Integer</haskell><br />
will now be parsed by a Haskell compiler to the most obvious meaning<br />
<haskell>2 :: Integer</haskell><br />
! :-)<br />
<br />
== Note ==<br />
<br />
This article is in category Proposals in order to show people that this idea was already proposed,<br />
but that one should think twice implementing it.<br />
There should be a category Counterproposals.<br />
<br />
<br />
== See also ==<br />
<br />
* The [[applicative-numbers]] package, which generates numeric class instances for arbitrary [[applicative functor]]s (including functions).<br />
* http://www.haskell.org/pipermail/haskell-cafe/2006-November/019374.html<br />
* http://www.haskell.org/pipermail/haskell-cafe/2006-October/019105.html<br />
* http://www.haskell.org/pipermail/haskell-cafe/2001-February/001531.html<br />
* http://augustss.blogspot.com/2009/02/regression-they-say-that-as-you-get.html<br />
<br />
[[Category:Humor]]<br />
[[Category:Proposals]]<br />
[[Category:FAQ]]<br />
[[Category:Style]]</div>Marcothttps://wiki.haskell.org/index.php?title=Creating_Debian_packages_from_Cabal_package&diff=33651Creating Debian packages from Cabal package2010-02-18T21:48:42Z<p>Marcot: PackageTemplate</p>
<hr />
<div>== Packaging a Cabal library package with haskell-devscripts for unstable ==<br />
<br />
This is a little bit outdated. For up-to-date information about packaging for Debian, with the Debian Haskell Group, check: http://wiki.debian.org/Haskell/CollabMaint/PackageTemplate<br />
<br />
This is the recommended way to package a Cabal library for Debian now. Example of how a package could be created, using:<br />
<br />
* $package as the package name<br />
* $version as the version of the package.<br />
* $maintainerName as the name of the maintainer<br />
* $maintainerEmail as the email of the maintainer<br />
* $packageShortDescription as the Cabal short description of the package<br />
* $packageLongDescription as the Cabal long description of the package<br />
<br />
<ol><br />
<li><tt>wget http://hackage.haskell.org/packages/archive/$package/$version/$package-$version.tar.gz -O haskell-${package}_$version.orig.tar.gz</tt></li><br />
<li><tt>tar -zxf haskell-$package_$version.orig.tar.gz</tt></li><br />
<li><tt>cd $package-$version</tt></li><br />
<li><tt>mkdir debian</tt></li><br />
<li><tt><pre>cat << EOF > debian/control<br />
Source: haskell-$package<br />
Section: libdevel<br />
Priority: optional<br />
Maintainer: $maintainerName <$maintainerEmail><br />
Standards-Version: 3.8.1<br />
Build-Depends: debhelper (>= 5), cdbs, dpatch, haskell-devscripts (>= 0.6.15+nmu1), ghc6, ghc6-prof<br />
Build-Depends-Indep: ghc6-doc, haddock, hscolour<br />
Homepage: http://hackage.haskell.org/cgi-bin/$package/package/$package<br />
<br />
Package: libghc6-$package-dev<br />
Architecture: any<br />
Depends: ${haskell:Depends}, ${shlibs:Depends}, ${misc:Depends}<br />
Suggests: libghc6-$package-doc (= ${binary:Version}), libghc6-$package-prof (= ${binary:Version})<br />
Description: $packageShortDescription<br />
This package provides a library for the Haskell programming language.<br />
See http://www.haskell.org/ for more information on Haskell.<br />
.<br />
$packageLongDescription<br />
<br />
Package: libghc6-$package-prof<br />
Architecture: any<br />
Depends: libghc6-$package-dev (= ${binary:Version}), ${haskell:Depends}, ${shlibs:Depends}, ${misc:Depends}<br />
Description: $packageShortDescription; profiling libraries<br />
This package provides a library for the Haskell programming language,<br />
compiled for profiling.<br />
See http://www.haskell.org/ for more information on Haskell.<br />
.<br />
$packageLongDescription<br />
<br />
Package: libghc6-$package-doc<br />
Section: doc<br />
Architecture: all<br />
Depends: ${misc:Depends}<br />
Recommends: ghc6-doc (>= 6.8.2)<br />
Suggests: libghc6-$package-dev (= ${binary:Version})<br />
Description: $packageShortDescription; documentation<br />
This package provides the documentation for a library for the Haskell<br />
programming language.<br />
See http://www.haskell.org/ for more information on Haskell.<br />
.<br />
$packageLongDescription<br />
EOF</pre><br />
# echo 5 > debian/compat<br />
# Create debian/copyright with your favorite editor:<br />
<pre>Debianised by ...<br />
Author ...<br />
Copyright: BSD ... /usr/share/common-licenses/BSD ...<br />
EOF</pre></tt></li><br />
<li><tt><pre>cat << EOF > debian/rules<br />
#!/usr/bin/make -f<br />
<br />
include /usr/share/cdbs/1/rules/debhelper.mk<br />
include /usr/share/cdbs/1/class/hlibrary.mk<br />
EOF</pre></tt></li><br />
<li><tt><pre>cat << EOF > debian/watch<br />
version=3<br />
http://hackage.haskell.org/packages/archive/$package/([\d\.]+)/$package-([\d\.]+).tar.gz<br />
EOF</pre></tt></li><br />
<li><tt>dch --create -D unstable --package haskell-$package --newversion $version-1</tt></li><br />
<li><tt>debuild -us -uc</tt></li></ol><br />
<br />
== Packaging a Cabal library package in 10 easy steps ==<br />
<br />
''This process requires the <tt>haskell-utils</tt> package.''<br />
<br />
Here is an example on was created a new Debian package out of an Haskell [[Cabal]] library package: [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mtl-1.0 mtl].<br />
<br />
<ol><br />
<li><tt>wget http://hackage.haskell.org/packages/archive/mtl/1.0/mtl-1.0.tar.gz -O haskell-mtl_1.0.1.orig.tar.gz</tt></li><br />
<li><tt>tar -zxf haskell-mtl_1.0.1.orig.tar.gz</tt></li><br />
<li><tt>cd mtl-1.0</tt></li><br />
<li><tt>mkdir -p debian/varfiles</tt></li><br />
<li>Create <tt>debian/varfiles/varfile</tt> with your favorite editor:<br />
<pre> maintainer="Ian Lynagh (wibble) <igloo@debian.org>"<br />
short_description="Haskell monad transformer library for GHC"<br />
long_description=" MTL is a monad transformer library, inspired by the paper \"Functional<br />
Programming with Overloading and Higher-Order Polymorphism\",<br />
by Mark P Jones (<http://www.cse.ogi.edu/~mpj/>), Advanced School<br />
of Functional Programming, 1995."<br />
c_dev_libs=""<br />
extra_build_deps=""</pre><br />
(Pay attention to the leading space in <tt>long_description</tt>. It's necessary due to the format of Debian's <tt>control</tt> file.)</li><br />
<li>Create <tt>debian/copyright</tt> with your favorite editor:<br />
<pre> Debianised by ...<br />
Author ...<br />
Copyright: BSD ... /usr/share/common-licenses/BSD ...<br />
EOF</pre></li><br />
<li><tt>dch --create -D unstable --package haskell-mtl --newversion 1.0.1-1</tt></li><br />
<li><tt>update-debian-haskell-files</tt></li><br />
<li><tt>debian/rules update-generated-files</tt></li><br />
<li><tt>debuild -us -uc</tt></li><br />
</ol><br />
<br />
With luck the <tt>.cabal</tt> file will provide most of the text for steps 5 and 6.<br />
<br />
When making future changes, apart from adding a changelog entry (use <tt>dch</tt>), only steps 9 and 10 need to be repeated.<br />
<br />
Even if packaging Haskell libraries seems easy, the [http://www.debian.org/doc/debian-policy/ Debian Policy] and the [http://www.debian.org/doc/developers-reference/ Developers Reference] contains a lot of valuable informations on how to create a policy compliant Debian package.<br />
<br />
Please subscribe to the [http://lists.debian.org/debian-haskell/ debian-haskell] mailling-list if you are interested in creating new Haskell packages for Debian.<br />
<br />
== Packaging a Cabal program package in N easy steps ==<br />
<br />
TBD</div>Marcothttps://wiki.haskell.org/index.php?title=Monomorphism_restriction&diff=31567Monomorphism restriction2009-11-13T18:55:58Z<p>Marcot: Add missing word</p>
<hr />
<div>The monomorphism restriction is probably the most annoying and controversial feature of Haskell's type system. All seem to agree that it is evil, but whether or not it is considered a necessary evil depends on who you ask.<br />
<br />
The definition of the restriction is fairly technical, but to a first approximation it means that you often cannot overload a function unless you provide an explicit type signature. In summary:<br />
<br />
<haskell><br />
-- This is allowed<br />
f1 x = show x<br />
<br />
-- This is not allowed<br />
f2 = \x -> show x<br />
<br />
-- ...but this is allowed<br />
f3 :: (Show a) => a -> String<br />
f3 = \x -> show x<br />
<br />
-- This is not allowed<br />
f4 = show<br />
<br />
-- ...but this is allowed<br />
f5 :: (Show a) => a -> String<br />
f5 = show<br />
</haskell><br />
<br />
Arguably, these should all be equivalent, but thanks to the monomorphism restriction, they are not.<br />
<br />
The difference between the first and second version is that the first version binds x via a "simple pattern binding" (see section 4.4.3.2 of the Haskell 98 report), and is therefore unrestricted, but the second version does not. The reason why one is allowed and the other is not is that it's considered clear that sharing f1 will not share any computation, and less clear that sharing f2 will have the same effect. If this seems arbitrary, that's because it is. It is difficult to design an objective rule which disallows subjective unexpected behaviour. Some people are going to fall foul of the rule even though they're doing quite reasonable things.<br />
<br />
So why is the restriction imposed? The reasoning behind it is fairly subtle, and is fully explained in the [http://haskell.org/onlinereport/ Haskell 98 report]. Basically, it solves one practical problem (without the restriction, there would be some ambiguous types) and one semantic problem (without the restriction, there would be some repeated evaluation where a programmer might expect the evaluation to be shared). Those who are for the restriction argue that these cases should be dealt with correctly. Those who are against the restriction argue that these cases are so rare that it's not worth sacrificing the type-independence of eta reduction.<br />
<br />
:An example, from [http://research.microsoft.com/~simonpj/papers/history-of-haskell/index.htm A History of Haskell]: Consider the <code>genericLength</code> function, from <code>Data.List</code><br />
<br />
:<haskell><br />
genericLength :: Num a => [b] -> a<br />
</haskell><br />
<br />
:And consider the function:<br />
<br />
<haskell><br />
f xs = (len,len)<br />
where<br />
len = genericLength xs<br />
</haskell><br />
<br />
:<code>len</code> has type <code>Num a => a</code> and, without the monomorphism restriction, it could be computed ''twice''. --[[User:ARG|ARG]]<br />
<br />
----<br />
<br />
''It is not clear to me how this whole thing about being computed once or twice works. Isn't type checking/inference something that happens at compile-time and shouldn't have any effect on what happens at run-time, as long as the typecheck passes? --dainichi''<br />
<br />
The trouble is that typeclasses essentially introduce additional function parameters -- specifically, the dictionary of code implementing the instances in question. In the case of typeclass polymorphic pattern bindings, you end up turning something that looked like a pattern binding -- a constant that would only ever be evaluated once, into what is really a function binding, something which will not be memoised. [[User:CaleGibbard|CaleGibbard]] 23:46, 1 February 2008 (UTC)<br />
<br />
The type of <code>f</code>, if no signature is given, then the compiler doesn't know that the two elements of the returned pair are of the same type. It's return value will be:<br />
<br />
<haskell><br />
f::(Num a, Num b) => [x] -> (a, b)<br />
</haskell><br />
<br />
This means that <i>while compiling f</i> the compiler is unable to memoise len - clearly if a /= b then different code is executed to compute the first and second appearance of len in the pair. It's possible the compiler could do something more clever <i>when f is actually applied</i> if a == b, but I'm supposing this isn't a straight-forward thing to implement in the compilers. [[User:Dozer|Dozer]] 23:54, 4 February 2008 (GMT)<br />
<br />
----<br />
<br />
Oversimplifying the debate somewhat: Those in favour tend to be those who have written Haskell [[Implementations]] and those against tend to be those who have written complex combinator libraries (and hence have hit their collective heads against the restriction all too often). It often boils down to the fact that programmers want to avoid [http://catb.org/esr/jargon/html/L/legalese.html legalese], and language implementors want to avoid [http://catb.org/esr/jargon/html/C/cruft.html cruft].<br />
<br />
In almost all cases, you can get around the restriction by including explicit type declarations. Those who are for the restriction are usually quick to point out that including explicit type declarations is good programming practice anyway. In a few very rare cases, however, you may need to supply a type signature which is not valid Haskell. (Such type signatures require a type system extension such as [[ScopedTypeVariables]].) Unless you're writing some weird combinator libraries, or are in the habit of not writing type declarations, you're unlikely to come across it. Even so, most Haskell [[Implementations]] provide a way to turn the restriction off.<br />
<br />
See also: [http://haskell.org/onlinereport/decls.html#sect4.5.5 Section 4.5.5, Haskell 98 report].<br />
<br />
-- [[Andrew Bromage]]<br />
<br />
Some question or suggestion: As I understand the problem arises from the situation that two different forms of assignment are described by the same notation. There are two forms of assignment, namely the inspection of data structures ("unpacking", "pattern binding") and the definition of functions ("function binding"). Unique examples are:<br />
<br />
<haskell><br />
let f x = y -- function definition<br />
let F x = y -- data structure decomposition<br />
</haskell><br />
<br />
In the first case we have the identifier f starting with lower case. This means this is a function binding. The second assignment starts with F, which must be a constructor. That's why this is a pattern binding. The monomorphism restriction applies only to the pattern binding. I think this was not defined in order to please compiler writers, but has shown to be useful in practice, or am I wrong? But the different handling of these binding types leads to a problem since both types have a common case.<br />
<br />
<haskell><br />
let x = y -- function or pattern binding?<br />
</haskell><br />
<br />
So, what speaks against differentiating the assignments notationally, say<br />
<br />
<haskell><br />
let f x = y -- function definition<br />
let F x <= y -- data structure decomposition<br />
</haskell><br />
<br />
and keep the monomorphism restriction as it is?<br />
<br />
-- [[Henning Thielemann]]<br />
<br />
The problem isn't just pattern bindings, it's that pattern bindings which are typeclass polymorphic are actually function bindings in disguise, since the usual implementation of typeclasses adds parameters to such definitions, to allow the definition to take the typeclass dictionaries involved. Thus, such pattern bindings have different properties with respect to sharing (they're generally less shared than you want). In especially bad cases, without the MR, it is possible to have programs which run exponentially slower without type signatures than when signatures are added. Just distinguishing pattern bindings with a new notation doesn't solve the problem, since they'll have to be converted into function bindings in that case anyway. If you intend to keep the MR, then you don't need to change anything. The issue with the MR is just the fact that it's annoying to have eta-reduction fail in the absence of explicit type signatures, and the fact that it makes otherwise perfectly valid programs fail to compile on speculation that there might be loss of sharing (when there usually isn't, or at least the impact isn't large enough to worry about).<br />
<br />
John Hughes recently advocated the removal of the MR on the Haskell Prime mailing list, and suggested replacing it with two forms of pattern binding: one for call-by-name (polymorphic, not shared), and one for call-by-need (monomorphic, guaranteed shared). This might be similar to what you're suggesting. If you look at it too closely, it seems like a good solution, but the overall impact on Haskell code seems too large to me, to resolve a distinction which it ought to be statically possible to determine.<br />
<br />
I'm of the opinion that it would be better to find a way to restore sharing lost through the typeclass transformation in some way, or else implement typeclasses in an altogether different way which doesn't run into this problem. Additional runtime machinery seems like a likely candidate for this -- the interactions with garbage collection are somewhat subtle, but I think it should be doable. It's also possible to restore the sharing via whole-program analysis, but advocates of separate compilation will probably complain, unless we were to find a mechanism to fix the problem from the object code (and potentially temporaries) at link time.<br />
<br />
:- [[Cale Gibbard]]<br />
<br />
--------------------<br />
I think it'd be useful to collect a set of examples of the Monormorphism Restriction biting people in an unexpected way. This may help to inform the debate over the MR by giving real-life examples. Add more examples here if (an only if) they constitute an unexpected MR-related incident in your life or someone else's. No invented examples! -- [[Simon Peyton Jones]]<br />
<br />
* GHC Trac bug [http://hackage.haskell.org/trac/ghc/ticket/1749 1749]<br />
* In trying to build an editor with undoable actions:<br />
<haskell><br />
class EditAction e a | e -> a where<br />
apply :: a -> e -> a<br />
<br />
data ListAction a = Append a | Remove<br />
<br />
instance EditAction (ListAction a) [a] where<br />
apply list (Append a) = a:list<br />
apply (x:xs) Remove = xs<br />
<br />
-- Apply all the EditActions to the input<br />
--edit :: EditAction e a => a -> [e] -> a -- monomorphism restriction - I have to put this in!<br />
edit = foldl apply<br />
</haskell><br />
<br />
----<br />
Back before forM was in the Control.Monad library, I once spent about 1/2 an hour trying to figure out why my action in the ST monad was having its '<hask>s</hask>' parameter squished to <hask>()</hask>. I tore the code apart for quite a while before discovering that it was that the MR was applying to my definition of <hask>forM</hask>:<br />
<br />
<haskell><br />
forM = flip mapM<br />
</haskell><br />
<br />
----<br />
<br />
<haskell><br />
import Graphics.UI.Gtk<br />
import Graphics.UI.Gtk.Glade<br />
<br />
-- xmlGetWidget' :: WidgetClass widget => (GObject -> widget) -> String -> IO widget<br />
xmlGetWidget' = xmlGetWidget undefined<br />
<br />
main :: IO ()<br />
main<br />
= do<br />
initGUI<br />
window <- xmlGetWidget' castToWindow "window1"<br />
button <- xmlGetWidget' castToButton "button1"<br />
widgetShowAll window<br />
mainGUI<br />
</haskell><br />
<br />
If I comment main, I cannot compile this code because of the monomorphism restriction. With main, it'll infer the type:<br />
<br />
<haskell><br />
xmlGetWidget' :: (GObject -> Window) -> String -> IO Window<br />
</haskell><br />
<br />
And give me a type error in the button line. If I uncomment the type signature, it'll work.<br />
<br />
----<br />
<br />
Along the same lines as Simon's question above, does anyone have any real examples of being bitten by the lack of MR? I know what it's for, but I can't really think of any realistic cases when it would be a problem. --pumpkin<br />
<br />
[[Category:Glossary]]<br />
[[Category:Language]]</div>Marcothttps://wiki.haskell.org/index.php?title=Monomorphism_restriction&diff=31566Monomorphism restriction2009-11-13T18:54:33Z<p>Marcot: Monormophism Restriction biting</p>
<hr />
<div>The monomorphism restriction is probably the most annoying and controversial feature of Haskell's type system. All seem to agree that it is evil, but whether or not it is considered a necessary evil depends on who you ask.<br />
<br />
The definition of the restriction is fairly technical, but to a first approximation it means that you often cannot overload a function unless you provide an explicit type signature. In summary:<br />
<br />
<haskell><br />
-- This is allowed<br />
f1 x = show x<br />
<br />
-- This is not allowed<br />
f2 = \x -> show x<br />
<br />
-- ...but this is allowed<br />
f3 :: (Show a) => a -> String<br />
f3 = \x -> show x<br />
<br />
-- This is not allowed<br />
f4 = show<br />
<br />
-- ...but this is allowed<br />
f5 :: (Show a) => a -> String<br />
f5 = show<br />
</haskell><br />
<br />
Arguably, these should all be equivalent, but thanks to the monomorphism restriction, they are not.<br />
<br />
The difference between the first and second version is that the first version binds x via a "simple pattern binding" (see section 4.4.3.2 of the Haskell 98 report), and is therefore unrestricted, but the second version does not. The reason why one is allowed and the other is not is that it's considered clear that sharing f1 will not share any computation, and less clear that sharing f2 will have the same effect. If this seems arbitrary, that's because it is. It is difficult to design an objective rule which disallows subjective unexpected behaviour. Some people are going to fall foul of the rule even though they're doing quite reasonable things.<br />
<br />
So why is the restriction imposed? The reasoning behind it is fairly subtle, and is fully explained in the [http://haskell.org/onlinereport/ Haskell 98 report]. Basically, it solves one practical problem (without the restriction, there would be some ambiguous types) and one semantic problem (without the restriction, there would be some repeated evaluation where a programmer might expect the evaluation to be shared). Those who are for the restriction argue that these cases should be dealt with correctly. Those who are against the restriction argue that these cases are so rare that it's not worth sacrificing the type-independence of eta reduction.<br />
<br />
:An example, from [http://research.microsoft.com/~simonpj/papers/history-of-haskell/index.htm A History of Haskell]: Consider the <code>genericLength</code> function, from <code>Data.List</code><br />
<br />
:<haskell><br />
genericLength :: Num a => [b] -> a<br />
</haskell><br />
<br />
:And consider the function:<br />
<br />
<haskell><br />
f xs = (len,len)<br />
where<br />
len = genericLength xs<br />
</haskell><br />
<br />
:<code>len</code> has type <code>Num a => a</code> and, without the monomorphism restriction, it could be computed ''twice''. --[[User:ARG|ARG]]<br />
<br />
----<br />
<br />
''It is not clear to me how this whole thing about being computed once or twice works. Isn't type checking/inference something that happens at compile-time and shouldn't have any effect on what happens at run-time, as long as the typecheck passes? --dainichi''<br />
<br />
The trouble is that typeclasses essentially introduce additional function parameters -- specifically, the dictionary of code implementing the instances in question. In the case of typeclass polymorphic pattern bindings, you end up turning something that looked like a pattern binding -- a constant that would only ever be evaluated once, into what is really a function binding, something which will not be memoised. [[User:CaleGibbard|CaleGibbard]] 23:46, 1 February 2008 (UTC)<br />
<br />
The type of <code>f</code>, if no signature is given, then the compiler doesn't know that the two elements of the returned pair are of the same type. It's return value will be:<br />
<br />
<haskell><br />
f::(Num a, Num b) => [x] -> (a, b)<br />
</haskell><br />
<br />
This means that <i>while compiling f</i> the compiler is unable to memoise len - clearly if a /= b then different code is executed to compute the first and second appearance of len in the pair. It's possible the compiler could do something more clever <i>when f is actually applied</i> if a == b, but I'm supposing this isn't a straight-forward thing to implement in the compilers. [[User:Dozer|Dozer]] 23:54, 4 February 2008 (GMT)<br />
<br />
----<br />
<br />
Oversimplifying the debate somewhat: Those in favour tend to be those who have written Haskell [[Implementations]] and those against tend to be those who have written complex combinator libraries (and hence have hit their collective heads against the restriction all too often). It often boils down to the fact that programmers want to avoid [http://catb.org/esr/jargon/html/L/legalese.html legalese], and language implementors want to avoid [http://catb.org/esr/jargon/html/C/cruft.html cruft].<br />
<br />
In almost all cases, you can get around the restriction by including explicit type declarations. Those who are for the restriction are usually quick to point out that including explicit type declarations is good programming practice anyway. In a few very rare cases, however, you may need to supply a type signature which is not valid Haskell. (Such type signatures require a type system extension such as [[ScopedTypeVariables]].) Unless you're writing some weird combinator libraries, or are in the habit of not writing type declarations, you're unlikely to come across it. Even so, most Haskell [[Implementations]] provide a way to turn the restriction off.<br />
<br />
See also: [http://haskell.org/onlinereport/decls.html#sect4.5.5 Section 4.5.5, Haskell 98 report].<br />
<br />
-- [[Andrew Bromage]]<br />
<br />
Some question or suggestion: As I understand the problem arises from the situation that two different forms of assignment are described by the same notation. There are two forms of assignment, namely the inspection of data structures ("unpacking", "pattern binding") and the definition of functions ("function binding"). Unique examples are:<br />
<br />
<haskell><br />
let f x = y -- function definition<br />
let F x = y -- data structure decomposition<br />
</haskell><br />
<br />
In the first case we have the identifier f starting with lower case. This means this is a function binding. The second assignment starts with F, which must be a constructor. That's why this is a pattern binding. The monomorphism restriction applies only to the pattern binding. I think this was not defined in order to please compiler writers, but has shown to be useful in practice, or am I wrong? But the different handling of these binding types leads to a problem since both types have a common case.<br />
<br />
<haskell><br />
let x = y -- function or pattern binding?<br />
</haskell><br />
<br />
So, what speaks against differentiating the assignments notationally, say<br />
<br />
<haskell><br />
let f x = y -- function definition<br />
let F x <= y -- data structure decomposition<br />
</haskell><br />
<br />
and keep the monomorphism restriction as it is?<br />
<br />
-- [[Henning Thielemann]]<br />
<br />
The problem isn't just pattern bindings, it's that pattern bindings which are typeclass polymorphic are actually function bindings in disguise, since the usual implementation of typeclasses adds parameters to such definitions, to allow the definition to take the typeclass dictionaries involved. Thus, such pattern bindings have different properties with respect to sharing (they're generally less shared than you want). In especially bad cases, without the MR, it is possible to have programs which run exponentially slower without type signatures than when signatures are added. Just distinguishing pattern bindings with a new notation doesn't solve the problem, since they'll have to be converted into function bindings in that case anyway. If you intend to keep the MR, then you don't need to change anything. The issue with the MR is just the fact that it's annoying to have eta-reduction fail in the absence of explicit type signatures, and the fact that it makes otherwise perfectly valid programs fail to compile on speculation that there might be loss of sharing (when there usually isn't, or at least the impact isn't large enough to worry about).<br />
<br />
John Hughes recently advocated the removal of the MR on the Haskell Prime mailing list, and suggested replacing it with two forms of pattern binding: one for call-by-name (polymorphic, not shared), and one for call-by-need (monomorphic, guaranteed shared). This might be similar to what you're suggesting. If you look at it too closely, it seems like a good solution, but the overall impact on Haskell code seems too large to me, to resolve a distinction which it ought to be statically possible to determine.<br />
<br />
I'm of the opinion that it would be better to find a way to restore sharing lost through the typeclass transformation in some way, or else implement typeclasses in an altogether different way which doesn't run into this problem. Additional runtime machinery seems like a likely candidate for this -- the interactions with garbage collection are somewhat subtle, but I think it should be doable. It's also possible to restore the sharing via whole-program analysis, but advocates of separate compilation will probably complain, unless we were to find a mechanism to fix the problem from the object code (and potentially temporaries) at link time.<br />
<br />
:- [[Cale Gibbard]]<br />
<br />
--------------------<br />
I think it'd be useful to collect a set of examples of the Monormorphism Restriction biting people in an unexpected way. This may help to inform the debate over the MR by giving real-life examples. Add more examples here if (an only if) they constitute an unexpected MR-related incident in your life or someone else's. No invented examples! -- [[Simon Peyton Jones]]<br />
<br />
* GHC Trac bug [http://hackage.haskell.org/trac/ghc/ticket/1749 1749]<br />
* In trying to build an editor with undoable actions:<br />
<haskell><br />
class EditAction e a | e -> a where<br />
apply :: a -> e -> a<br />
<br />
data ListAction a = Append a | Remove<br />
<br />
instance EditAction (ListAction a) [a] where<br />
apply list (Append a) = a:list<br />
apply (x:xs) Remove = xs<br />
<br />
-- Apply all the EditActions to the input<br />
--edit :: EditAction e a => a -> [e] -> a -- monomorphism restriction - I have to put this in!<br />
edit = foldl apply<br />
</haskell><br />
<br />
----<br />
Back before forM was in the Control.Monad library, I once spent about 1/2 an hour trying to figure out why my action in the ST monad was having its '<hask>s</hask>' parameter squished to <hask>()</hask>. I tore the code apart for quite a while before discovering that it was that the MR was applying to my definition of <hask>forM</hask>:<br />
<br />
<haskell><br />
forM = flip mapM<br />
</haskell><br />
<br />
----<br />
<br />
<haskell><br />
import Graphics.UI.Gtk<br />
import Graphics.UI.Gtk.Glade<br />
<br />
-- xmlGetWidget' :: WidgetClass widget => (GObject -> widget) -> String -> IO widget<br />
xmlGetWidget' = xmlGetWidget undefined<br />
<br />
main :: IO ()<br />
main<br />
= do<br />
initGUI<br />
window <- xmlGetWidget' castToWindow "window1"<br />
button <- xmlGetWidget' castToButton "button1"<br />
widgetShowAll window<br />
mainGUI<br />
</haskell><br />
<br />
If I comment main, I cannot compile this code because of the monomorphism restriction. With, it'll infer the type:<br />
<br />
<haskell><br />
xmlGetWidget' :: (GObject -> Window) -> String -> IO Window<br />
</haskell><br />
<br />
And give me a type error in the button line. If I uncomment the type signature, it'll work.<br />
<br />
----<br />
<br />
Along the same lines as Simon's question above, does anyone have any real examples of being bitten by the lack of MR? I know what it's for, but I can't really think of any realistic cases when it would be a problem. --pumpkin<br />
<br />
[[Category:Glossary]]<br />
[[Category:Language]]</div>Marcothttps://wiki.haskell.org/index.php?title=IRC_channel&diff=28214IRC channel2009-05-15T13:36:15Z<p>Marcot: Added #haskell.t</p>
<hr />
<div>Internet Relay Chat is a worldwide text chat service with many thousands<br />
of users among various irc networks.<br />
<br />
The Freenode IRC network hosts the large #haskell channel, and we've had<br />
up to 699 concurrent users (average is 581), making the channel<br />
[http://searchirc.com/search.php?SCHANS=1&SSORT=SIZE&N=freenode the 5th largest]<br />
of the 7000 channels on freenode (Feb 2009). One famous<br />
resident is [[Lambdabot]], another is [http://hpaste.org hpaste] (see<br />
the [[#Bots|Bots]] section below).<br />
<br />
The IRC channel can be an excellent place to learn more about Haskell,<br />
and to just keep in the loop on new things in the Haskell world. Many<br />
new developments in the Haskell world first appear on the irc channel.<br />
<br />
Since 2009, the Haskell channel has grown large enough that we've split it in two parts:<br />
<br />
* #haskell, for all the usual things<br />
* #haskell-in-depth , for those seeking in depth, or more theoretical discussion<br />
<br />
As always, #haskell remains the primary place for new user questions.<br />
<br />
--------------------------<br />
<br />
[http://haskell.org/sitewiki/images/3/3c/Haskell-current.png [[Image:Haskell-current-small.png|thumb|The #haskell social graph, Jan 2008]]]<br />
<br />
[[Image:Irc-raw.png|thumb|Daily traffic in #haskell since 2004]]<br />
<br />
[[Image:Nick-activity.png|thumb|Growth of #haskell]]<br />
<br />
[[Image:Haskell-wordle-irc.png|thumb|Haskell noun map]]<br />
<br />
== Getting there ==<br />
<br />
If you point your irc client to [irc://chat.freenode.net/haskell chat.freenode.net] and then join the #haskell channel, you'll be there. Alternately, you can try [http://www.mibbit.com/ mibbit.com] which connects inside the browser.<br />
<br />
Example, using [http://www.irssi.org/ irssi]:<br />
<br />
$ irssi -c chat.freenode.net -n myname -w mypassword<br />
/join #haskell<br />
<br />
Tip, if you're using Emacs to edit your Haskell sources then why not use it to chat about Haskell? Check out [http://www.emacswiki.org/cgi-bin/wiki/EmacsIRCClient ERC], The Emacs IRC client. Invoke it like this and follow the commands:<br />
<br />
M-x erc-select<br />
...<br />
/join #haskell<br />
<br />
[[Image:Irc--haskell-screenshot.png|frame|A screenshot of an irssi session in #haskell]]<br />
<br />
== Principles ==<br />
<br />
The #haskell channel is a very friendly, welcoming place to hang out,<br />
teach and learn. The goal of #haskell is to encourage learning and<br />
discussion of Haskell, functional programming, and programming in<br />
general. As part of this we welcome newbies, and encourage teaching of<br />
the language.<br />
<br />
Part of the #haskell success comes from the approach that the community<br />
is quite tight knit -- we know each other -- it's not just a homework<br />
channel. As a result, many collaborative projects have arisen between<br />
Haskell irc channel citizens.<br />
<br />
To maintain the friendly, open culture, the following is required:<br />
<br />
* Low to zero tolerance for ridiculing questions. Insulting new users is unacceptable<br />
<br />
New Haskell users should feel entirely comfortable asking new questions.<br />
Helpful answers should be encouraged with <hask>name++</hask> karma<br />
points, in public, as a reward for providing a good answer.<br />
<br />
As the channel grows, we see a diverse range of people, with different<br />
programming backgrounds, trying to make their way with Haskell. A good<br />
rule of thumb, to avoid frustration is:<br />
<br />
* approach negative comments by asking for details (kind of like [http://en.wikipedia.org/wiki/Socratic_method Socratic questioning]), rather than challenging the competence of the writer (ad hominem).<br />
<br />
<br />
== History ==<br />
<br />
The #haskell channel appeared in the late 90s, and really got going<br />
in early 2001, with the help of Shae Erisson (aka shapr).<br />
<br />
A fairly extensive analysis of the traffic on #haskell over the years is<br />
[http://www.cse.unsw.edu.au/~dons/irc/ kept here]<br />
<br />
== Related channels ==<br />
<br />
In addition to the main Haskell channel there are also:<br />
<br />
{| border="1" cellspacing="0" cellpadding="5" align="center"<br />
! Channel<br />
! Purpose<br />
|-<br />
| #haskell.cz<br />
| Czech speakers (UTF-8)<br />
|- <br />
| #haskell.de<br />
| German speakers<br />
|-<br />
| #haskell.dut<br />
| Dutch speakers<br />
|-<br />
| #haskell.es<br />
| Spanish speakers<br />
|-<br />
| #haskell.fi<br />
| Finnish speakers<br />
|-<br />
| #haskell.fr <br />
| French speakers <br />
|-<br />
| #haskell.hr<br />
| Croatian speakers<br />
|-<br />
| #haskell.it <br />
| Italian speakers<br />
|-<br />
| #haskell.jp <br />
| Japanese speakers<br />
|-<br />
| #haskell.no <br />
| Norwegian speakers<br />
|-<br />
| #haskell.pt<br />
| Portuguese speakers<br />
|-<br />
| #haskell.ru <br />
| Russian speakers. Seems that most of them migrated to Jabber conference (haskell@conference.jabber.ru).<br />
|-<br />
| #haskell_ru <br />
| Russian speakers again, in UTF-8. For those, who prefer good ol' IRC channel with a lambdabot.<br />
|-<br />
| #haskell.se <br />
| Swedish speakers<br />
|-<br />
| #haskell-overflow<br />
| Overflow conversations<br />
|-<br />
| #haskell-blah <br />
| Haskell people talking about anything except Haskell itself<br />
|-<br />
| #haskell-books <br />
| Authors organizing the collaborative writing of the [http://en.wikibooks.org/wiki/Haskell Haskell wikibook] and other books or tutorials.<br />
|-<br />
| #gentoo-haskell <br />
| [[Gentoo]]/Linux specific Haskell conversations<br />
|-<br />
| #arch-haskell <br />
| [[Arch Linux]]/ specific Haskell conversations<br />
|-<br />
|-<br />
| #darcs <br />
| [[Darcs]] revision control channel (written in Haskell)<br />
|-<br />
| #perl6 <br />
| [http://www.pugscode.org Perl 6] development (plenty of Haskell chat there too)<br />
|-<br />
| #happs<br />
| [http://happs.org HAppS] Haskell Application Server channel<br />
|-<br />
| #xmonad<br />
| [http://xmonad.org Xmonad] a tiling window manager written in Haskell<br />
|}<br />
<br />
== Logs ==<br />
<br />
'''Logs''' are kept at a few places, including<br />
<br />
* [http://tunes.org/~nef/logs/haskell/ tunes.org]<br />
* [http://ircbrowse.com/cdates.html?channel=haskell IRCBrowse]<br />
<br />
<br />
== Bots ==<br />
<br />
=== Lambdabot ===<br />
<br />
[[Lambdabot]] provides many useful services for visitors to the IRC channel. Check out its wiki page for information on its commands.<br />
<br />
=== Hpaste ===<br />
The hpaste bot provides a notification interface to the [http://hpaste.org hpaste pastebin]. [[Hpaste.el|Emacs integration]] is available.<br />
<br />
=== Hackage ===<br />
The hackage bot provides real-time notifications of new package uploads to [http://hackage.haskell.org Hackage].<br />
<br />
== Locations ==<br />
<br />
To get an overview of where everybody on the channel might<br />
be, physically, please visit [[Haskell user locations]].<br />
<br />
<br />
[[Category:Community]]</div>Marcothttps://wiki.haskell.org/index.php?title=Creating_Debian_packages_from_Cabal_package&diff=27174Creating Debian packages from Cabal package2009-03-23T14:56:13Z<p>Marcot: Packaging a Cabal library package with haskell-devscripts for unstable</p>
<hr />
<div>== Packaging a Cabal library package with haskell-devscripts for unstable ==<br />
<br />
This is the recommended way to package a Cabal library for Debian now. Example of how a package could be created, using:<br />
<br />
* $package as the package name<br />
* $version as the version of the package.<br />
* $maintainerName as the name of the maintainer<br />
* $maintainerEmail as the email of the maintainer<br />
* $packageShortDescription as the Cabal short description of the package<br />
* $packageLongDescription as the Cabal long description of the package<br />
<br />
<ol><br />
<li><tt>wget http://hackage.haskell.org/packages/archive/$package/$version/$package-$version.tar.gz -O haskell-$package_$version.orig.tar.gz</tt></li><br />
<li><tt>tar -zxf haskell-$package_$version.orig.tar.gz</tt></li><br />
<li><tt>cd $package-$version</tt></li><br />
<li><tt>mkdir debian</tt></li><br />
<li><tt><pre>cat << EOF > debian/control<br />
Source: haskell-$package<br />
Section: libdevel<br />
Priority: optional<br />
Maintainer: $maintainerName <$maintainerEmail><br />
Standards-Version: 3.8.1<br />
Build-Depends: debhelper (>= 5), cdbs, dpatch, haskell-devscripts (>= 0.6.15+nmu1), ghc6, ghc6-prof<br />
Build-Depends-Indep: ghc6-doc, haddock, hscolour<br />
Homepage: http://hackage.haskell.org/cgi-bin/$package/package/$package<br />
<br />
Package: libghc6-$package-dev<br />
Architecture: any<br />
Depends: ${haskell:Depends}, ${shlibs:Depends}, ${misc:Depends}<br />
Suggests: libghc6-$package-doc (= ${binary:Version}), libghc6-$package-prof (= ${binary:Version})<br />
Description: $packageShortDescription<br />
This package provides a library for the Haskell programming language.<br />
See http://www.haskell.org/ for more information on Haskell.<br />
.<br />
$packageLongDescription<br />
<br />
Package: libghc6-$package-prof<br />
Architecture: any<br />
Depends: libghc6-$package-dev (= ${binary:Version}), ${haskell:Depends}, ${shlibs:Depends}, ${misc:Depends}<br />
Description: $packageShortDescription; profiling libraries<br />
This package provides a library for the Haskell programming language,<br />
compiled for profiling.<br />
See http://www.haskell.org/ for more information on Haskell.<br />
.<br />
$packageLongDescription<br />
<br />
Package: libghc6-$package-doc<br />
Section: doc<br />
Architecture: all<br />
Depends: ${misc:Depends}<br />
Recommends: ghc6-doc (>= 6.8.2)<br />
Suggests: libghc6-$package-dev (= ${binary:Version})<br />
Description: $packageShortDescription; documentation<br />
This package provides the documentation for a library for the Haskell<br />
programming language.<br />
See http://www.haskell.org/ for more information on Haskell.<br />
.<br />
$packageLongDescription<br />
EOF</pre><br />
# echo 5 > debian/compat<br />
# Create debian/copyright with your favorite editor:<br />
<pre>Debianised by ...<br />
Author ...<br />
Copyright: BSD ... /usr/share/common-licenses/BSD ...<br />
EOF</pre></tt></li><br />
<li><tt><pre>cat << EOF > debian/rules<br />
#!/usr/bin/make -f<br />
<br />
include /usr/share/cdbs/1/rules/debhelper.mk<br />
include /usr/share/cdbs/1/class/hlibrary.mk<br />
EOF</pre></tt></li><br />
<li><tt><pre>cat << EOF > debian/watch<br />
version=3<br />
http://hackage.haskell.org/packages/archive/$package/([\d\.]+)/$package-([\d\.]+).tar.gz<br />
EOF</pre></tt></li><br />
<li><tt>dch --create -D unstable --package haskell-$package --newversion $version-1</tt></li><br />
<li><tt>debuild -us -uc</tt></li></ol><br />
<br />
== Packaging a Cabal library package in 10 easy steps ==<br />
<br />
''This process requires the <tt>haskell-utils</tt> package.''<br />
<br />
Here is an example on was created a new Debian package out of an Haskell [[Cabal]] library package: [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mtl-1.0 mtl].<br />
<br />
<ol><br />
<li><tt>wget http://hackage.haskell.org/packages/archive/mtl/1.0/mtl-1.0.tar.gz -O haskell-mtl_1.0.1.orig.tar.gz</tt></li><br />
<li><tt>tar -zxf haskell-mtl_1.0.1.orig.tar.gz</tt></li><br />
<li><tt>cd mtl-1.0</tt></li><br />
<li><tt>mkdir -p debian/varfiles</tt></li><br />
<li>Create <tt>debian/varfiles/varfile</tt> with your favorite editor:<br />
<pre> maintainer="Ian Lynagh (wibble) <igloo@debian.org>"<br />
short_description="Haskell monad transformer library for GHC"<br />
long_description=" MTL is a monad transformer library, inspired by the paper \"Functional<br />
Programming with Overloading and Higher-Order Polymorphism\",<br />
by Mark P Jones (<http://www.cse.ogi.edu/~mpj/>), Advanced School<br />
of Functional Programming, 1995."<br />
c_dev_libs=""<br />
extra_build_deps=""</pre><br />
(Pay attention to the leading space in <tt>long_description</tt>. It's necessary due to the format of Debian's <tt>control</tt> file.)</li><br />
<li>Create <tt>debian/copyright</tt> with your favorite editor:<br />
<pre> Debianised by ...<br />
Author ...<br />
Copyright: BSD ... /usr/share/common-licenses/BSD ...<br />
EOF</pre></li><br />
<li><tt>dch --create -D unstable --package haskell-mtl --newversion 1.0.1-1</tt></li><br />
<li><tt>update-debian-haskell-files</tt></li><br />
<li><tt>debian/rules update-generated-files</tt></li><br />
<li><tt>debuild -us -uc</tt></li><br />
</ol><br />
<br />
With luck the <tt>.cabal</tt> file will provide most of the text for steps 5 and 6.<br />
<br />
When making future changes, apart from adding a changelog entry (use <tt>dch</tt>), only steps 9 and 10 need to be repeated.<br />
<br />
Even if packaging Haskell libraries seems easy, the [http://www.debian.org/doc/debian-policy/ Debian Policy] and the [http://www.debian.org/doc/developers-reference/ Developers Reference] contains a lot of valuable informations on how to create a policy compliant Debian package.<br />
<br />
Please subscribe to the [http://lists.debian.org/debian-haskell/ debian-haskell] mailling-list if you are interested in creating new Haskell packages for Debian.<br />
<br />
== Packaging a Cabal program package in N easy steps ==<br />
<br />
TBD</div>Marcothttps://wiki.haskell.org/index.php?title=GNU/Linux&diff=27172GNU/Linux2009-03-23T14:25:35Z<p>Marcot: IRC Channel and new list for Debian</p>
<hr />
<div>Haskell support on various Linux distributions. How to find Haskell applications and tools, contribute new packages, and get help for your distribution.<br />
<br />
* [http://haskell.org/ghc/download_ghc_6_10_1.html#binaries Download GHC for Linux]<br />
<br />
Mostly distributions should provide:<br />
<br />
* GHC<br />
* Core libraries<br />
* Core development tools<br />
* Cabal and cabal-install<br />
<br />
Optionally they provide parts of the emerging [http://haskell.org/haskellwiki/Haskell_Platform Haskell Platform].<br />
<br />
==Arch Haskell==<br />
<br />
http://www.thelin-xportal.com/albums/files/arch.jpg<br />
<br />
[http://wiki.archlinux.org/index.php/Haskell_package_guidelines Main Arch Haskell site]<br />
<br />
{|<br />
| Wiki<br />
| [http://wiki.archlinux.org/index.php/Haskell_package_guidelines Arch Haskell Wiki]<br />
|-<br />
| Blog<br />
| [http://archhaskell.wordpress.com/ Arch Haskell Blog]<br />
|-<br />
| IRC<br />
| #arch-haskell @ freenode.org<br />
|-<br />
| Applications<br />
| [http://haskell.org/haskellwiki/Arch_Linux/Applications Haskell applications provided on Arch Linux]<br />
|-<br />
| Libraries<br />
| [http://aur.archlinux.org/packages.php?O=0&L=0&C=0&K=arch-haskell&SeB=m&SB=n&SO=a&PP=100&do_Search=Go Haskell libraries on Arch Linux]<br />
|-<br />
| Tools<br />
| [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cabal2arch cabal2arch]<br />
|}<br />
<br />
==Debian GNU/Linux==<br />
<br />
[http://www.debian.org Debian Gnu/Linux] provides a good toolchain for Haskell development<br />
<br />
* Libraries: The most important packages are available in the [http://packages.debian.org/stable/devel/ stable], [http://packages.debian.org/testing/devel/ testing] and [http://packages.debian.org/unstable/devel/ unstable] trees.<br />
* Applications:<br />
* Mailing list: [http://lists.debian.org/debian-haskell/ debian-haskell]<br />
* Wiki:<br />
* IRC channel: #debian-haskell @ irc.debian.org<br />
* Making new packages: .deb from .cabal is a [[Creating_Debian_packages_from_Cabal_package|fairly easy process]]. <br />
<br />
==Fedora==<br />
<br />
[https://fedoraproject.org/wiki/SIGs/Haskell Fedora Haskell SIG Page]<br />
<br />
* Applications/Libraries: [https://bugzilla.redhat.com/buglist.cgi?product=Fedora&component=Package+Review&bug_status=CLOSED&emailcc1=1&emailtype1=substring&email1=fedora-haskell-list%40redhat.com Closed package reviews CC'd to fedora-haskell-list]<br />
* Mailing list: [http://www.redhat.com/mailman/listinfo/fedora-haskell-list fedora-haskell-list]<br />
* IRC channel: The #fedora-haskell IRC channel on Freenode<br />
<br />
==Gentoo==<br />
[[Gentoo]]<br />
<br />
http://www.gentoo.org/images/icon-gentoo.png<br />
<br />
<br />
{|<br />
| IRC<br />
| #gentoo-haskell @ freenode.org<br />
|-<br />
| Applications<br />
| [http://packages.gentoo.org/category/dev-haskell Haskell applications and libraries provided on Gentoo Linux]<br />
|-<br />
| Tools<br />
| [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackport hackport]<br />
|}<br />
<br />
<br />
==Slackware Linux==<br />
Slackware does not have official Haskell support.<br />
<br />
An unofficial Slackware repository for Haskell tools, library and<br />
programs [http://gorgias.mine.nu/slack/ is available here]. This repository works with [http://software.jaos.org/#slapt-get slapt-get] and [http://swaret.sourceforge.net/index.php swaret].<br />
<br />
Tools: [http://gorgias.mine.nu/repos/slackBuild/ slackbuild]<br />
<br />
==Ubuntu==<br />
This is pretty much the same as Debian, providing you add the 'universe' and/or 'multiverse' repositories, which import Debian packages and recompile them to match Ubuntu dependencies. The exact versions of packages may be different from Debian, but they tend to be ahead of Debian stable (sometimes by a long way).<br />
<br />
[[Category:OS]]</div>Marcothttps://wiki.haskell.org/index.php?title=Livros_e_tutoriais&diff=24739Livros e tutoriais2008-12-13T21:30:51Z<p>Marcot: Mini-curso EMSL</p>
<hr />
<div>* [http://marcot.iaaeee.org/mini-curso.pdf Mini-curso prático] sobre programação funcional apresentado no [http://emsl.softwarelivre.org EMSL].</div>Marcothttps://wiki.haskell.org/index.php?title=Xmonad/Using_xmonad_in_Gnome&diff=22558Xmonad/Using xmonad in Gnome2008-08-21T15:39:46Z<p>Marcot: Save session</p>
<hr />
<div>{{xmonad}}<br />
[[Category:XMonad]]<br />
<br />
==Introduction==<br />
<br />
[[Image:Screen-nomeata-ewhm.png|200px|A screenshot of xmonad cooperating with gnome|center]]<br />
<br />
Xmonad makes an excellent drop-in replacement for Gnome's default window manager (metacity) giving you a slick tiling window manager. This guide will help you set up Gnome to use Xmonad 0.7.<br />
<br />
This is an update to the previous page on [[Xmonad/Using xmonad in Gnome/0.6]].<br />
<br />
==Setting up Gnome to use Xmonad==<br />
<br />
===.gnomerc===<br />
<br />
The easiest way is to let Gnome start Xmonad itself by setting the environment variable WINDOW_MANAGER to point to the xmonad executable before the Gnome session manager starts. The best way to do this is to edit ''~/.gnomerc'' to contain:<br />
<br />
export WINDOW_MANAGER=xmonad<br />
<br />
If the binary is not in one of the directories in your $PATH, you must give the full path, i.e.:<br />
<br />
export WINDOW_MANAGER=${HOME}/bin/xmonad<br />
<br />
If Gnome is hanging on startup, try placing the following lines in ''~/.xsession'' instead:<br />
<br />
export WINDOW_MANAGER=xmonad<br />
exec gnome-session --purge-delay=3000<br />
<br />
===gnome-session===<br />
<br />
Another way to do this is to configure the session. Go to ''gnome-session-properties'' (or Desktop -> Preferences -> Sessions) -> Current Session, select Metacity and change style to Trash. Add ''xmonad'' to Startup Programs and run:<br />
<br />
$ killall metacity; xmonad &<br />
<br />
Close all programs, and in ''gnome-session-properties'', go to Session Options and click on Remember Currently Running Applications.<br />
<br />
==Configure Xmonad to interoperate with Gnome==<br />
<br />
[[Image:Screen-xmonad-gnome-darktheme4.jpg|200px|xmonad and gnome-panel|center]]<br />
<br />
Put this in ''~/.xmonad/xmonad.hs'':<br />
<br />
<haskell><br />
import XMonad<br />
import XMonad.Actions.CopyWindow<br />
import XMonad.Hooks.ManageDocks<br />
import XMonad.Hooks.EwmhDesktops<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Util.EZConfig<br />
<br />
main = xmonad $ defaultConfig<br />
{ manageHook = manageDocks <+> manageHook defaultConfig<br />
, logHook = ewmhDesktopsLogHook<br />
, layoutHook = ewmhDesktopsLayout $ avoidStruts<br />
$ layoutHook defaultConfig<br />
, modMask = mod4Mask<br />
}<br />
`additionalKeysP` myKeys<br />
<br />
myWorkspaces = map (:[]) ['1' .. '9']<br />
<br />
myKeys :: [([Char], X ())]<br />
myKeys = [ ("M-S-c", kill1)<br />
]<br />
-- This enables view switching, window shifting, and window copying<br />
++ [("M" ++ m ++ ('-':k:[]) , windows $ f i)<br />
| (i, k) <- zip myWorkspaces ['1'..'9']<br />
, (f, m) <- [(W.view, ""), (W.shift, "-S"), (copy, "-C-S")]]<br />
</haskell><br />
<br />
This should set up Xmonad to make space for Gnome's panel and status bar automatically. Note that this requires xmonad-contrib to be installed. (The myKeys part isn't needed for a minimal install but that was something that gave me problems early on. See the XMonad.Utils.EZConfig documentation for details.)<br />
<br />
Depending on your versions of nautilus and xmonad, step 4.1 (Disabling the nautilus desktop, see below) may be mandatory. (Otherwise, the nautilus desktop will be raised into the floating layer where it covers all your other windows.)<br />
<br />
Having done this, you should now be able to use Gnome with Xmonad, and most things will work. (An example of something that doesn't is iconifying windows from the panel window list.)<br />
<br />
Explanations of the various options are given below, along with some other things you might want to tweak.<br />
<br />
[[Image:screen-ohmega-tab-gnome-twopane.jpg|200px|A screenshot of xmonad cooperating with gnome|center]]<br />
<br />
==Tweak Gnome to work better with Xmonad==<br />
<br />
These are a few steps that greatly improves the experience of running Xmonad under Gnome. Note that on some systems the binary <tt>gconftool</tt> is called <tt>gconftool-2</tt>.<br />
<br />
===Disable the Nautilus desktop===<br />
<br />
This step is not required, but some users prefer to disable the desktop. From the command line execute:<br />
<br />
gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false<br />
<br />
(Using recent gnome and xmonad I found that it was necessary.)<br />
<br />
===Changing desktop background===<br />
<br />
If you need to change the workspace background programmatically (i.e. from some extension setting in xmonad's configuration file), you can use the command:<br />
<br />
gconftool --type string --set /desktop/gnome/background/picture_filename "/path/to/your/image.png"<br />
<br />
==Tips on configuring Xmonad==<br />
<br />
All the configuration is done in <tt>~/.xmonad/xmonad.hs</tt>.<br />
<br />
===Change the mod key===<br />
<br />
The default ''mod key'' is ''alt'', which conflicts with Gnome keybindings. In order to use be able to use the keyboard to e.g. getting rid of dialogues we rebind it to the left ''logo key'':<br />
<br />
<haskell><br />
main = xmonad defaultConfig<br />
{ modMask = mod4Mask<br />
}<br />
</haskell><br />
<br />
===Extended Window Manager Hints===<br />
<br />
[http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html EwmhDesktops] makes it possible to let Gnome know about Xmonad windows and workspaces. ''EwmhDesktops'' has been enabled in the example configuration above. By itself, configuration looks like this:<br />
<br />
<haskell><br />
import XMonad.Hooks.EwmhDesktops<br />
main = xmonad defaultConfig<br />
{ logHook = ewmhDesktopsLogHook<br />
}<br />
</haskell><br />
<br />
===Key bindings for switching desktops===<br />
<br />
====In 1 dimension: CycleWS====<br />
<br />
Gnome lays out the desktops in a row by default, and uses Ctrl+Alt+Left/Right for switching desktops left/right. To get similar behaviour in Xmonad, you need to add some keybindings. The contrib module [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-CycleWS.html XMonad.Actions.CycleWS] has some useful actions for cycling workspaces, and I use these keybindings:<br />
<br />
<haskell><br />
-- moving workspaces<br />
, ("M-<Left>", prevWS )<br />
, ("M-<Right>", nextWS )<br />
, ("M-S-<Left>", shiftToPrev )<br />
, ("M-S-<Right>", shiftToNext )<br />
</haskell><br />
<br />
[[Image:Xmonad-screen-gnome-brownblack5.jpg|center|200px]]<br />
<br />
====In 2 dimensions: Plane====<br />
<br />
If Gnome is configured to lay out desktops in more than one line, it's possible to navigate with Ctrl+Alt+Up/Bottom also. The contrib module XMonad.Actions.Plane, available in the [http://code.haskell.org/xmonad darcs] version of XMonad, provides support for this kind of navigation. To use it with 3 lines, for instance, you could use this configuration:<br />
<br />
<haskell><br />
[ ((keyMask .|. m, keySym), function 3 Finite direction)<br />
| (keySym, direction) <- zip [xK_Left .. xK_Down] $ enumFrom ToLeft<br />
, (keyMask, function) <- [(0, planeMove), (shiftMask, planeShift)]<br />
]<br />
</haskell><br />
<br />
===Logging out of the Gnome session vs. quitting Xmonad===<br />
<br />
When running Xmonad as above, it is launched by ''gnome-session'', the "Gnome session manager." Quitting Xmonad in this situation ''will not log you out.'' If you make no changes, using mod+shift+q will leave you with all your applications still running and no window manager to navigate them! There are several remedies for this.<br />
<br />
* Run 'xmonad &' from a command line.<br />
* Quit X using Alt-Ctrl-Backspace.<br />
* Rebind mod+shift+q<br />
<br />
====Rebind mod+shift+q====<br />
To avoid exiting Xmonad and being stuck with no window manager, you might rebind mod+shift+q to execute the gnome-session "log out" functionality. This will of course prevent you from "quitting" Xmonad in the normal way, which may or may not be desirable. When the session logs out, the X11 server is terminated, which will in turn terminate all running X11 applications, including Xmonad.<br />
<br />
(TODO: improve the description of changes that need to be made here.)<br />
<br />
, ("M-S-q", spawn "gnome-session-save --gui --kill") )<br />
<br />
==== Configure rudimentary power management ====<br />
<br />
It might be useful to include bindings for hibernation, screen locking, and other assorted basic functions. While Gnome provides the capability to do so, it's functionality is limited (Mod4 cannot be used as a mask), and you may prefer to have Xmonad manage it. Fortunately, these things can be controlled from the command line, and the following bindings may help. (NB: These are for one handed use of Dvorak control; make sure to bind them to something more fitting. They also use mod1 not to clash with mod4 by accident.)<br />
<br />
-- Lock Screen<br />
, ((modMask .|. shiftMask, xK_l), spawn "gnome-screensaver-command -l")<br />
-- Logout<br />
, ((modMask .|. mod1Mask .|. shiftMask, xK_l), spawn "gnome-session-save --gui --kill")<br />
-- Sleep<br />
, ((mod1Mask .|. shiftMask, xK_apostrophe), spawn "gnome-power-cmd.sh suspend")<br />
-- Reboot<br />
, ((mod1Mask .|. shiftMask, xK_comma), spawn "gnome-power-cmd.sh hibernate")<br />
-- Deep Sleep<br />
, ((mod1Mask .|. shiftMask, xK_period), spawn "gnome-power-cmd.sh hibernate")<br />
-- Death<br />
, ((mod1Mask .|. shiftMask, xK_p), spawn "gnome-power-cmd.sh shutdown")<br />
<br />
<br />
====Configure the session manager to relaunch Xmonad====<br />
You can configure the Gnome Session Manager to restart Xmonad whenever it exits (i.e., if you haven't rebound mod-shift-q.) This is rarely a useful feature as xmonad has its builtin compile-and-restart (mod-q), but it will prevent you from accidentally ending up with no window manager and no way to launch one.<br />
<br />
However, as of version 0.7, XMonad does not itself communicate with any session managers in they way they prefer, so setting things up takes some hackery:<br />
<br />
(TBD: steps, see also [[Xmonad/Using_xmonad_in_Gnome/0.5#Preparing_your_GNOME_session]])</div>Marcothttps://wiki.haskell.org/index.php?title=Xmonad/Using_xmonad_in_Gnome&diff=22551Xmonad/Using xmonad in Gnome2008-08-21T01:41:21Z<p>Marcot: Using gnome-session to start XMonad</p>
<hr />
<div>{{xmonad}}<br />
[[Category:XMonad]]<br />
<br />
==Introduction==<br />
<br />
[[Image:Screen-nomeata-ewhm.png|200px|A screenshot of xmonad cooperating with gnome|center]]<br />
<br />
Xmonad makes an excellent drop-in replacement for Gnome's default window manager (metacity) giving you a slick tiling window manager. This guide will help you set up Gnome to use Xmonad 0.7.<br />
<br />
This is an update to the previous page on [[Xmonad/Using xmonad in Gnome/0.6]].<br />
<br />
==Setting up Gnome to use Xmonad==<br />
<br />
===.gnomerc===<br />
<br />
The easiest way is to let Gnome start Xmonad itself by setting the environment variable WINDOW_MANAGER to point to the xmonad executable before the Gnome session manager starts. The best way to do this is to edit ''~/.gnomerc'' to contain:<br />
<br />
export WINDOW_MANAGER=xmonad<br />
<br />
If the binary is not in one of the directories in your $PATH, you must give the full path, i.e.:<br />
<br />
export WINDOW_MANAGER=${HOME}/bin/xmonad<br />
<br />
If Gnome is hanging on startup, try placing the following lines in ''~/.xsession'' instead:<br />
<br />
export WINDOW_MANAGER=xmonad<br />
exec gnome-session --purge-delay=3000<br />
<br />
===gnome-session===<br />
<br />
Another way to do this is to configure the session. Go to ''gnome-session-properties'' (or Desktop -> Preferences -> Sessions) -> Current Session, select Metacity and change style to Trash. Add ''xmonad'' to Startup Programs and run:<br />
<br />
$ killall metacity; xmonad<br />
<br />
In Current Session, change XMonad style to Restart.<br />
<br />
==Configure Xmonad to interoperate with Gnome==<br />
<br />
[[Image:Screen-xmonad-gnome-darktheme4.jpg|200px|xmonad and gnome-panel|center]]<br />
<br />
Put this in ''~/.xmonad/xmonad.hs'':<br />
<br />
<haskell><br />
import XMonad<br />
import XMonad.Actions.CopyWindow<br />
import XMonad.Hooks.ManageDocks<br />
import XMonad.Hooks.EwmhDesktops<br />
import qualified XMonad.StackSet as W<br />
import XMonad.Util.EZConfig<br />
<br />
main = xmonad $ defaultConfig<br />
{ manageHook = manageDocks <+> manageHook defaultConfig<br />
, logHook = ewmhDesktopsLogHook<br />
, layoutHook = ewmhDesktopsLayout $ avoidStruts<br />
$ layoutHook defaultConfig<br />
, modMask = mod4Mask<br />
}<br />
`additionalKeysP` myKeys<br />
<br />
myWorkspaces = map (:[]) ['1' .. '9']<br />
<br />
myKeys :: [([Char], X ())]<br />
myKeys = [ ("M-S-c", kill1)<br />
]<br />
-- This enables view switching, window shifting, and window copying<br />
++ [("M" ++ m ++ ('-':k:[]) , windows $ f i)<br />
| (i, k) <- zip myWorkspaces ['1'..'9']<br />
, (f, m) <- [(W.view, ""), (W.shift, "-S"), (copy, "-C-S")]]<br />
</haskell><br />
<br />
This should set up Xmonad to make space for Gnome's panel and status bar automatically. Note that this requires xmonad-contrib to be installed. (The myKeys part isn't needed for a minimal install but that was something that gave me problems early on. See the XMonad.Utils.EZConfig documentation for details.)<br />
<br />
Depending on your versions of nautilus and xmonad, step 4.1 (Disabling the nautilus desktop, see below) may be mandatory. (Otherwise, the nautilus desktop will be raised into the floating layer where it covers all your other windows.)<br />
<br />
Having done this, you should now be able to use Gnome with Xmonad, and most things will work. (An example of something that doesn't is iconifying windows from the panel window list.)<br />
<br />
Explanations of the various options are given below, along with some other things you might want to tweak.<br />
<br />
[[Image:screen-ohmega-tab-gnome-twopane.jpg|200px|A screenshot of xmonad cooperating with gnome|center]]<br />
<br />
==Tweak Gnome to work better with Xmonad==<br />
<br />
These are a few steps that greatly improves the experience of running Xmonad under Gnome. Note that on some systems the binary <tt>gconftool</tt> is called <tt>gconftool-2</tt>.<br />
<br />
===Disable the Nautilus desktop===<br />
<br />
This step is not required, but some users prefer to disable the desktop. From the command line execute:<br />
<br />
gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false<br />
<br />
(Using recent gnome and xmonad I found that it was necessary.)<br />
<br />
===Changing desktop background===<br />
<br />
If you need to change the workspace background programmatically (i.e. from some extension setting in xmonad's configuration file), you can use the command:<br />
<br />
gconftool --type string --set /desktop/gnome/background/picture_filename "/path/to/your/image.png"<br />
<br />
==Tips on configuring Xmonad==<br />
<br />
All the configuration is done in <tt>~/.xmonad/xmonad.hs</tt>.<br />
<br />
===Change the mod key===<br />
<br />
The default ''mod key'' is ''alt'', which conflicts with Gnome keybindings. In order to use be able to use the keyboard to e.g. getting rid of dialogues we rebind it to the left ''logo key'':<br />
<br />
<haskell><br />
main = xmonad defaultConfig<br />
{ modMask = mod4Mask<br />
}<br />
</haskell><br />
<br />
===Extended Window Manager Hints===<br />
<br />
[http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-EwmhDesktops.html EwmhDesktops] makes it possible to let Gnome know about Xmonad windows and workspaces. ''EwmhDesktops'' has been enabled in the example configuration above. By itself, configuration looks like this:<br />
<br />
<haskell><br />
import XMonad.Hooks.EwmhDesktops<br />
main = xmonad defaultConfig<br />
{ logHook = ewmhDesktopsLogHook<br />
}<br />
</haskell><br />
<br />
===Key bindings for switching desktops===<br />
<br />
====In 1 dimension: CycleWS====<br />
<br />
Gnome lays out the desktops in a row by default, and uses Ctrl+Alt+Left/Right for switching desktops left/right. To get similar behaviour in Xmonad, you need to add some keybindings. The contrib module [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-CycleWS.html XMonad.Actions.CycleWS] has some useful actions for cycling workspaces, and I use these keybindings:<br />
<br />
<haskell><br />
-- moving workspaces<br />
, ("M-<Left>", prevWS )<br />
, ("M-<Right>", nextWS )<br />
, ("M-S-<Left>", shiftToPrev )<br />
, ("M-S-<Right>", shiftToNext )<br />
</haskell><br />
<br />
[[Image:Xmonad-screen-gnome-brownblack5.jpg|center|200px]]<br />
<br />
====In 2 dimensions: Plane====<br />
<br />
If Gnome is configured to lay out desktops in more than one line, it's possible to navigate with Ctrl+Alt+Up/Bottom also. The contrib module XMonad.Actions.Plane, available in the [http://code.haskell.org/xmonad darcs] version of XMonad, provides support for this kind of navigation. To use it with 3 lines, for instance, you could use this configuration:<br />
<br />
<haskell><br />
[ ((keyMask .|. m, keySym), function 3 Finite direction)<br />
| (keySym, direction) <- zip [xK_Left .. xK_Down] $ enumFrom ToLeft<br />
, (keyMask, function) <- [(0, planeMove), (shiftMask, planeShift)]<br />
]<br />
</haskell><br />
<br />
===Logging out of the Gnome session vs. quitting Xmonad===<br />
<br />
When running Xmonad as above, it is launched by ''gnome-session'', the "Gnome session manager." Quitting Xmonad in this situation ''will not log you out.'' If you make no changes, using mod+shift+q will leave you with all your applications still running and no window manager to navigate them! There are several remedies for this.<br />
<br />
* Run 'xmonad &' from a command line.<br />
* Quit X using Alt-Ctrl-Backspace.<br />
* Rebind mod+shift+q<br />
<br />
====Rebind mod+shift+q====<br />
To avoid exiting Xmonad and being stuck with no window manager, you might rebind mod+shift+q to execute the gnome-session "log out" functionality. This will of course prevent you from "quitting" Xmonad in the normal way, which may or may not be desirable. When the session logs out, the X11 server is terminated, which will in turn terminate all running X11 applications, including Xmonad.<br />
<br />
(TODO: improve the description of changes that need to be made here.)<br />
<br />
, ("M-S-q", spawn "gnome-session-save --gui --kill") )<br />
<br />
==== Configure rudimentary power management ====<br />
<br />
It might be useful to include bindings for hibernation, screen locking, and other assorted basic functions. While Gnome provides the capability to do so, it's functionality is limited (Mod4 cannot be used as a mask), and you may prefer to have Xmonad manage it. Fortunately, these things can be controlled from the command line, and the following bindings may help. (NB: These are for one handed use of Dvorak control; make sure to bind them to something more fitting. They also use mod1 not to clash with mod4 by accident.)<br />
<br />
-- Lock Screen<br />
, ((modMask .|. shiftMask, xK_l), spawn "gnome-screensaver-command -l")<br />
-- Logout<br />
, ((modMask .|. mod1Mask .|. shiftMask, xK_l), spawn "gnome-session-save --gui --kill")<br />
-- Sleep<br />
, ((mod1Mask .|. shiftMask, xK_apostrophe), spawn "gnome-power-cmd.sh suspend")<br />
-- Reboot<br />
, ((mod1Mask .|. shiftMask, xK_comma), spawn "gnome-power-cmd.sh hibernate")<br />
-- Deep Sleep<br />
, ((mod1Mask .|. shiftMask, xK_period), spawn "gnome-power-cmd.sh hibernate")<br />
-- Death<br />
, ((mod1Mask .|. shiftMask, xK_p), spawn "gnome-power-cmd.sh shutdown")<br />
<br />
<br />
====Configure the session manager to relaunch Xmonad====<br />
You can configure the Gnome Session Manager to restart Xmonad whenever it exits (i.e., if you haven't rebound mod-shift-q.) This is rarely a useful feature as xmonad has its builtin compile-and-restart (mod-q), but it will prevent you from accidentally ending up with no window manager and no way to launch one.<br />
<br />
However, as of version 0.7, XMonad does not itself communicate with any session managers in they way they prefer, so setting things up takes some hackery:<br />
<br />
(TBD: steps, see also [[Xmonad/Using_xmonad_in_Gnome/0.5#Preparing_your_GNOME_session]])</div>Marcothttps://wiki.haskell.org/index.php?title=Prime_numbers&diff=21857Prime numbers2008-07-19T16:00:12Z<p>Marcot: x -> n</p>
<hr />
<div>== Simple Prime Sieve ==<br />
The following is an elegant way to generate a list of all the prime numbers in the universe:<br />
<br />
<haskell><br />
primes :: [Integer]<br />
primes = sieve [2..]<br />
where sieve (p:xs) = p : sieve [x | x<-xs, x `mod` p /= 0]<br />
</haskell><br />
<br />
While simple, this method is rather inefficient and not recommended for more than the first 1000 prime numbers. For every number <hask>x</hask>, it will test <hask>x `mod` p /= 0</hask> for all prime numbers <hask>p</hask> that are smaller than the smallest prime factor of <hask>x</hask>.<br />
<br />
Given an infinite list of prime numbers, we can implement primality tests and integer factorization:<br />
<br />
<haskell><br />
isPrime n = n > 1 && n == head (factorize n)<br />
<br />
primeFactors 1 = []<br />
primeFactors n = go n primes<br />
where<br />
go n ps@(p:pt)<br />
| p*p > n = [n]<br />
| n `rem` p == 0 = p : go (n `quot` p) ps<br />
| otherwise = go n pt<br />
</haskell><br />
<br />
== Simple Prime Sieve II ==<br />
The following method is slightly faster and works well for the first 5000 primes:<br />
<br />
<haskell><br />
primes :: [Integer]<br />
primes = 2:filter isPrime [3,5..]<br />
where<br />
isPrime n = all (not . divides n) $ takeWhile (\p -> p*p <= n) primes<br />
divides n p = n `mod` p == 0 <br />
</haskell><br />
<br />
Compared to the previous sieve, it only tests odd numbers and avoids testing for prime factors of <math>n</math> that are larger than <math>\sqrt{n}</math>.<br />
<br />
== Prime Wheels ==<br />
<br />
The idea of only testing odd numbers can be extended further. For instance, it is a useful fact that every prime number other than 2 and 3 must be of the form <math>6k+1</math> or <math>6k+5</math>. Thus, we only need to test these numbers:<br />
<br />
<haskell><br />
primes :: [Integer]<br />
primes = 2:3:primes'<br />
where<br />
1:p:candidates = [6*k+r | k <- [0..], r <- [1,5]]<br />
primes' = p : filter isPrime candidates<br />
isPrime n = all (not . divides n) $ takeWhile (\p -> p*p <= n) primes'<br />
divides n p = n `mod` p == 0<br />
</haskell><br />
<br />
Here, <hask>primes'</hask> is the list of primes greater than 3 and <hask>isPrime</hask> does not test for divisibility by 2 or 3 because the <hask>candidates</hask> by construction don't have these numbers as factors. We also need to exclude 1 from the candidates and mark the next one as prime to start the recursion.<br />
<br />
Such a scheme to generate candidate numbers that avoid the first a given set of primes as divisors is called a '''prime wheel'''. Imagine that you had a wheel of circumference 6 to be rolled along the number line. With spikes positioned 1 and 5 units around the circumference, rolling the wheel will prick holes exactly in those positions on the line whose numbers are not divisible by 2 and 3.<br />
<br />
A wheel can be represented by its circumference and the spiked positions.<br />
<haskell><br />
data Wheel = Wheel Int [Int]<br />
</haskell><br />
We prick out numbers by rolling the wheel.<br />
<haskell><br />
roll (Wheel n rs) = [n*k+r | k <- [0..], r <- rs]<br />
</haskell><br />
The smallest wheel is the unit wheel with one spike, it will prick out every number.<br />
<haskell><br />
w0 = Wheel 1 [1]<br />
</haskell><br />
We can create a larger wheel by rolling a smaller wheel of circumference <hask>n</hask> along a rim of circumference <hask>p*n</hask> while excluding spike positions at multiples of <hask>p</hask>.<br />
<haskell><br />
nextSize (Wheel n rs) p =<br />
Wheel (p*n) [r' | k <- [0..(p-1)], r <- rs, let r' = n*k+r, r' `mod` p /= 0]<br />
</haskell><br />
Combining both, we can make wheels that prick out numbers that avoid a given list <hask>ds</hask> of divisors.<br />
<haskell><br />
mkWheel ds = foldl nextSize w0 ds<br />
</haskell><br />
<br />
Now, we can generate prime numbers with a wheel that for instance avoids all multiples of 2, 3, 5 and 7.<br />
<haskell><br />
primes :: [Integer]<br />
primes = small ++ large<br />
where<br />
1:p:candidates = roll $ mkWheel small<br />
small = [2,3,5,7]<br />
large = p : filter isPrime candidates<br />
isPrime n = all (not . divides n) $ takeWhile (\p -> p*p <= n) large<br />
divides n p = n `mod` p == 0<br />
</haskell><br />
It's a pretty big wheel with a circumference of 210 and allows us to calculate the first 10000 primes in convenient time.<br />
<br />
A fixed size wheel is fine, but how about adapting the wheel size while generating prime numbers? See the [[Research papers/Functional pearls|functional pearl]] titled [http://citeseer.ist.psu.edu/runciman97lazy.html Lazy wheel sieves and spirals of primes] for more.<br />
<br />
== Implicit Heap ==<br />
<br />
The following is a more efficient prime generator, implementing the sieve of<br />
Eratosthenes.<br />
<br />
See also the message threads [http://thread.gmane.org/gmane.comp.lang.haskell.cafe/25270/focus=25312 Re: "no-coding" functional data structures via lazyness] for more about how merging ordered lists amounts to creating an implicit heap and [http://thread.gmane.org/gmane.comp.lang.haskell.cafe/26426/focus=26493 Re: Code and Perf. Data for Prime Finders] for an explanation of the <hask>People a</hask> structure that makes it work when tying a knot.<br />
<br />
<haskell><br />
data People a = VIP a (People a) | Crowd [a]<br />
<br />
mergeP :: Ord a => People a -> People a -> People a<br />
mergeP (VIP x xt) ys = VIP x $ mergeP xt ys<br />
mergeP (Crowd xs) (Crowd ys) = Crowd $ merge xs ys<br />
mergeP xs@(Crowd ~(x:xt)) ys@(VIP y yt) = case compare x y of<br />
LT -> VIP x $ mergeP (Crowd xt) ys<br />
EQ -> VIP x $ mergeP (Crowd xt) yt<br />
GT -> VIP y $ mergeP xs yt<br />
<br />
<br />
merge :: Ord a => [a] -> [a] -> [a]<br />
merge xs@(x:xt) ys@(y:yt) = case compare x y of<br />
LT -> x : merge xt ys<br />
EQ -> x : merge xt yt<br />
GT -> y : merge xs yt<br />
<br />
diff xs@(x:xt) ys@(y:yt) = case compare x y of<br />
LT -> x : diff xt ys<br />
EQ -> diff xt yt<br />
GT -> diff xs yt<br />
<br />
foldTree :: (a -> a -> a) -> [a] -> a<br />
foldTree f ~(x:xs) = f x . foldTree f . pairs $ xs<br />
where pairs ~(x: ~(y:ys)) = f x y : pairs ys<br />
<br />
primes, nonprimes :: [Integer]<br />
primes = 2:3:diff [5,7..] nonprimes<br />
nonprimes = serve . foldTree mergeP . map multiples $ tail primes<br />
where<br />
multiples p = vip [p*k | k <- [p,p+2..]]<br />
<br />
vip (x:xs) = VIP x $ Crowd xs<br />
serve (VIP x xs) = x:serve xs<br />
serve (Crowd xs) = xs<br />
</haskell><br />
<br />
<hask>nonprimes</hask> effectively implements a heap, exploiting lazy evaluation.<br />
<br />
== Bitwise prime sieve ==<br />
<br />
Count the number of prime below a given 'n'. Shows fast bitwise arrays,<br />
and an example of Template Haskell to defeat your enemies.<br />
<br />
<haskell><br />
{-# OPTIONS -O2 -optc-O -XBangPatterns #-}<br />
module Primes (nthPrime) where<br />
<br />
import Control.Monad.ST<br />
import Data.Array.ST<br />
import Data.Array.Base<br />
import System<br />
import Control.Monad<br />
import Data.Bits<br />
<br />
nthPrime :: Int -> Int<br />
nthPrime n = runST (sieve n)<br />
<br />
sieve n = do<br />
a <- newArray (3,n) True :: ST s (STUArray s Int Bool)<br />
let cutoff = truncate (sqrt $ fromIntegral n) + 1<br />
go a n cutoff 3 1<br />
<br />
go !a !m cutoff !n !c<br />
| n >= m = return c<br />
| otherwise = do<br />
e <- unsafeRead a n<br />
if e then<br />
if n < cutoff then<br />
let loop !j<br />
| j < m = do<br />
x <- unsafeRead a j<br />
when x $ unsafeWrite a j False<br />
loop (j+n)<br />
| otherwise = go a m cutoff (n+2) (c+1)<br />
in loop ( if n < 46340 then n * n else n `shiftL` 1)<br />
else go a m cutoff (n+2) (c+1)<br />
else go a m cutoff (n+2) c<br />
</haskell><br />
<br />
And places in a module:<br />
<br />
<haskell><br />
{-# OPTIONS -fth #-}<br />
import Primes<br />
<br />
main = print $( let x = nthPrime 10000000 in [| x |] )<br />
</haskell><br />
<br />
Run as:<br />
<br />
<haskell><br />
$ ghc --make -o primes Main.hs<br />
$ time ./primes<br />
664579<br />
./primes 0.00s user 0.01s system 228% cpu 0.003 total<br />
</haskell><br />
<br />
== Miller-Rabin Primality Test ==<br />
<haskell><br />
find2km :: Integral a => a -> (a,a)<br />
find2km n = f 0 n<br />
where <br />
f k m<br />
| r == 1 = (k,m)<br />
| otherwise = f (k+1) q<br />
where (q,r) = quotRem m 2 <br />
<br />
millerRabinPrimality :: Integer -> Integer -> Bool<br />
millerRabinPrimality n a<br />
| a <= 1 || a >= n-1 = <br />
error $ "millerRabinPrimality: a out of range (" <br />
++ show a ++ " for "++ show n ++ ")" <br />
| n < 2 = False<br />
| even n = False<br />
| b0 == 1 || b0 == n' = True<br />
| otherwise = iter (tail b)<br />
where<br />
n' = n-1<br />
(k,m) = find2km n'<br />
b0 = powMod n a m<br />
b = take (fromIntegral k) $ iterate (squareMod n) b0<br />
iter [] = False<br />
iter (x:xs)<br />
| x == 1 = False<br />
| x == n' = True<br />
| otherwise = iter xs<br />
<br />
pow' :: (Num a, Integral b) => (a -> a -> a) -> (a -> a) -> a -> b -> a<br />
pow' _ _ _ 0 = 1<br />
pow' mul sq x' n' = f x' n' 1<br />
where <br />
f x n y<br />
| n == 1 = x `mul` y<br />
| r == 0 = f x2 q y<br />
| otherwise = f x2 q (x `mul` y)<br />
where<br />
(q,r) = quotRem n 2<br />
x2 = sq x<br />
<br />
mulMod :: Integral a => a -> a -> a -> a<br />
mulMod a b c = (b * c) `mod` a<br />
squareMod :: Integral a => a -> a -> a<br />
squareMod a b = (b * b) `rem` a<br />
powMod :: Integral a => a -> a -> a -> a<br />
powMod m = pow' (mulMod m) (squareMod m)<br />
</haskell><br />
<br />
== Using IntSet for a traditional sieve ==<br />
<haskell><br />
<br />
module Sieve where<br />
import qualified Data.IntSet as I<br />
<br />
-- findNext - finds the next member of an IntSet.<br />
findNext c is | I.member c is = c<br />
| c > I.findMax is = error "Ooops. No next number in set." <br />
| otherwise = findNext (c+1) is<br />
<br />
-- mark - delete all multiples of n from n*n to the end of the set<br />
mark n is = is I.\\ (I.fromAscList (takeWhile (<=end) (map (n*) [n..])))<br />
where<br />
end = I.findMax is<br />
<br />
-- primes - gives all primes up to n <br />
primes n = worker 2 (I.fromAscList [2..n])<br />
where<br />
worker x is <br />
| (x*x) > n = is<br />
| otherwise = worker (findNext (x+1) is) (mark x is)<br />
</haskell><br />
[[Category:Code]]</div>Marcothttps://wiki.haskell.org/index.php?title=File:Captura_da_tela.png&diff=21788File:Captura da tela.png2008-07-15T22:48:19Z<p>Marcot: Link correction</p>
<hr />
<div>XMonad with [[/Marcot's xmonad.hs]].</div>Marcothttps://wiki.haskell.org/index.php?title=Xmonad/Config_archive&diff=21787Xmonad/Config archive2008-07-15T22:07:44Z<p>Marcot: Marcot's screenshot</p>
<hr />
<div>{{xmonad}}<br />
<br />
==xmonad configuration examples==<br />
<br />
Configuration files (Config.hs for xmonad < 0.5, xmonad.hs for xmonad >= 0.5)<br />
<br />
Many config files marked as 0.5 probably work in 0.6 as well; give it a try and ask on the #xmonad IRC channel on freenode.org if you have problems.<br />
<br />
For more screenshots see the [[Xmonad/Screenshots]] archive.<br />
<br />
;[[/Template xmonad.hs (0.7)]]<br />
;[[/Template xmonad.hs]] (0.6)<br />
:The default xmonad settings, in the form of a template, so you can easily edit and replace any values.<br />
<br />
;[[/Don's xmonad.hs]] (0.5,0.6,0.7)<br />
:[[/Don's Config.hs]] (0.4)<br />
:colours, use custom terminal, dynamicLogDzen<br />
[[Image:Xmonad-screen-dons-code.png|center|200px]]<br />
<br />
;[[/Gwern's Config.hs]] (0.7-; darcs)<br />
:[[/Gwern's Config.hs (0.4)]] (old)<br />
:Ratpoison-y keybindings; example usage of XSelection.<br />
<br />
;[[/twifkak's xmonad.hs]] (0.5)<br />
:[[/twifkak's Config.hs]] (0.4)<br />
:modMask = mod4Mask; noBorders tabbed layout; keybindings for dzen, rotview, swapworkspaces, windowbringer, and windownavigation; urgencyhook (only in darcs xmonad).<br />
<br />
;[[/nomeatas Config.hs]] (0.4)<br />
:modMaks = mod4Mask; gnome-stuff<br />
<br />
;[[/David Roundy's xmonad.hs]] (0.5)<br />
:Combo config for small screen + xclock. Requires the xmonad-library branch, so not for the faint of heart. This config also keeps mod=mod1, and therefore moves a number of key bindings to non-standard locations (my laptop has no spare modifier keys).<br />
[[Image:droundy-config.png|center|200px]]<br />
<br />
;[[/Brent Yorgey's xmonad.hs]] (0.6)<br />
:[[/Brent Yorgey's darcs xmonad.hs]] (darcs)<br />
:modMask = mod4Mask; DynamicLog, RotView, ViewPrev, WindowNavigation, ToggleLayouts (toggle full screen mode), UrgencyHook + dzen, FlexibleManipulate, a bunch of Prompts, Submap, Search, and a few others, with keybindings for all! (Warning: lots of non-standard keybindings. =)<br />
[[Image:byorgey-config.png|center|200px]]<br />
<br />
;[[/Robert Manea's xmonad.hs]] (0.5)<br />
:[[/Robert Manea's Config.hs and support scripts]] (0.4)<br />
:Customized DynamicLog and ShellPrompt, ManageDock, some efforts to make the colors of all components go together well<br />
0.4 screenshot: [[Image:rob-config.png|center|400px]]<br />
0.5 screenshot: [[Image:Xmonad_shellprompt_newconf.png|center|400px]]<br />
<br />
;[[/Eric Mertens' xmonad.hs]] (0.5)<br />
:[[/Eric Mertens's Config.hs]] (0.4)<br />
:Customized DynamicLog, ShellPrompt, TilePrime, Dual-head and an effort to make the statusbar similar to DWM.<br />
[[Image:glguy-config.jpg|center|400px]]<br />
<br />
;[[/vvv's xmonad.hs]] (0.5-0.7)<br />
:[[/vvv's Config.hs]] (0.4)<br />
:CustomKeys, CycleWS, {Shell,Ssh,Man}Prompt, Submap, DynamicWorkspaces, NoBorders, and ion-like status bar written in nonkosher Perl.<br />
[[Image:vvv-config.png|center|200px]]<br />
<br />
;[[/Andrea Rossato's xmonad.hs]] (0.5)<br />
:[[/arossato's Config.hs]] (0.4)<br />
:Tabbed, Xmobar with DynamicLog, (Shell|Ssh|Man)Prompt.<br />
[[Image:Arossato-config.png|center|200px]]<br />
<br />
;[[/Octoploid's xmonad.hs]] (0.7)<br />
:Xmobar with customized DynamicLog, CycleWS with custom keys, colors, terminal, golden ratio<br />
[[Image:Octoploid_conf.png|center|200px]]<br />
<br />
;[[/Ray's xmonad.hs]] (0.5)<br />
:DynamicLog, custom manageHook, changed from default terminal, border colors, prompts, and layouts. Pseudo-Haskell dzen statusbar with greek letters for workspace names.<br />
[[Image:Ray-config.png|center|200px]]<br />
<br />
;[[/nattfodd's xmonad.hs]] (0.7/darcs)<br />
:DynamicLog, smartBorders, French keyboard, defaultGap, urgencyHook in workspace toolbar and some prompts.<br />
[[Image:Nattfodd-xmonad-0.7.png|center|200px]]<br />
<br />
;[[/deifl's xmonad.hs]] (0.5)<br />
:DynamicLog, WindowBringer, CopyWindow, ResizableTile, Tabbed layout. not default terminal, changed colors and some instances of dzen.<br />
Clean: [[Image:D_xmonad_clear.jpg|center|200px]]<br />
Populated: [[Image:D_xmonad_full.jpg|center|200px]]<br />
<br />
;[[/Xilon's xmonad.hs]] (0.5)<br />
:Simple and clean setup with dzen and a tray. Dzen with workspaces uses UrgencyHook for Urgent windows.<br />
[[Image:xilon-config.png|center|200px]]<br />
<br />
; [[/skorpan's xmonad.hs]] (0.7)<br />
: Pretty clean setup. I use conky-cli with dzen2 at the bottom of the screenshot, which is not included here.<br />
[[Image:Skorpan.png|center|200px]]<br />
<br />
;[[/loupgaroublonds xmonad.hs]] (0.5)<br />
: mostly a stock config but with support for gnome and my cat<br />
[[Image:loupgaroublond-config.png|center|200px]]<br />
<br />
;[[/cce xmonad.hs]] (0.5)<br />
: alt+enter full screen, alt+hjkl to navigate, many remapped keys<br />
<br />
;[[/entropies xmonad.hs]] (0.5)<br />
: windows as meta key, fullscreen & noborders on keypress for client. custom keybindings. magnifier.<br />
[[Image:entropie-config.png|center|200px]]<br />
<br />
; [[/brad's xmonad.hs]] (0.7)<br />
: very basic, just some cosmetic and key-shortcut changes<br />
[[Image:brad.png|center|200px]]<br />
<br />
; [[/Lee Aylward's xmonad.hs]] (0.5)<br />
: Resizable Tall, NoBorders, dzen DynamicLog, rhythmbox control shortcuts, windows key<br />
[[Image:leeaylward.png|center|400px]]<br />
<br />
; [[/oxymor00n's xmonad.hs]] (darcs)<br />
: [[/oxymor00n's xmobarrc]]<br />
: Tabbed layout, Floating Layout, xmobar, EZConfig for Emacs-like keybinding-definition, added some bindings for the mouse wheel (cycle focus and cycle workspaces), cycleWS-stuff that might be interesting for Xinerama-users,...<br />
[[Image:oxymor00n-xmonad.png|center|200px]]<br />
<br />
<br />
; [[/Andrea Spada xmonad.hs]] (0.6)<br />
: Tall, Resizable Mosaic and Combo, EvmhDesktops, additional keybindings - Work In Progress...<br />
<br />
; [[/Wfarr's xmonad.hs]] (0.6/darcs)<br />
: ResizableTall Layout using EZConfig, cycleWS, CopyWindows, and DZen to get some cool stuff happening.<br />
[[Image:Wfarrscreen1.png|center|200px]]<br />
<br />
; [[/lithis's xmonad.hs]] (darcs)<br />
; [[/lithis's xmobarrc]] (darcs)<br />
: The screenshot shows xmobar, two screens, a spiral layout, a tabbed layout, XFT fonts, and ShellPrompt with tab completion. The config also has pointer follows focus.<br />
[[Image:lithis-xmonad.png|center|200px]]<br />
<br />
; [[/andrewsw's xmonad.hs]] (0.6)<br />
; [[/andrewsw's .Xdefault]]<br />
: These screenshots show some compositing and nice transparent urxvt's with a circle layout and a magnified grid layout.<br />
<br />
[[Image:Xmonad-circle-comp.jpg|center|200px]]<br />
[[Image:Xmonad-mag-grid.jpg|center|200px]]<br />
<br />
; [[/sykopomp's xmonad.hs]] (darcs)<br />
; [[/sykopomp's xmonad.dv-vi.hs]]<br />
; This screeshot shows xfce-panel with pager + xmonad in a ResizableTall layout. Also using compositing and transparent urxvt's (thanks andrewsw) with bindings for changing transparency on focused window. Keybindings have been completely redone to be more similar to emacs-bindings (M-p and M-n for previous and next windows). The other config is an older config that uses the standard vi-like bindings, but translated by location to a dvorak layout.<br />
[[Image:xmonad-screen-xinerama-composite-xfce.jpg|center|200px]]<br />
<br />
; [[/sphynx's xmonad.hs]] (darcs)<br />
; Emacs-style keybindings, xmobar integration, XFT-fonts, ManageDocks, Tabbed layout, IM layout for Pidgin and Skype configured through PerWorkspace, Search extension for wikipedia, translation and google, usage of CopyWindow to 'make window always visible', Urgency hook, PerWorkspace usage, Scratchpad terminal, custom styles for prompt and borders.<br />
<br />
; [[/thoughtpolice's xmonad.hs]] (darcs)<br />
; [[/thoughtpolice's xmobarrc]] (0.9)<br />
; Emacs-esque keyboard bindings via EZConfig, dynamicLog with dzen, Submap google/hoogle/amazon/imdb/youtube/wikipedia searching, Shell & Ssh modules, slightly custom XPConfig and avoidStruts (ManageDocks.)<br />
<br />
; [[/Remi's xmonad.hs]] (0.7)<br />
; [[/Remi's .xmobarrc]] (0.8)<br />
; [[/Remi's .xinitrc]]<br />
: Lots of key bindings for destkop-navigation/moving, xmonad.hs-editing, music, next-N-windows-float-hack. xmobar integration and PerWorkspace Layouts. And a yet-to-be-published libmpd xmobar plugin.<br />
<br />
[[Image:Remi-xmonad-screenshot.png|center|200px]]<br />
<br />
; [[/TeXitoi's xmonad.hs]] (0.7)<br />
; French keyboard, ManageDock, EwmhDesktops. Minimal configuration file with Defaults not overwritten. Mist GTK theme is used.<br />
<br />
[[Image:Xmonad-xfce-panel.png|center|200px]]<br />
<br />
; [[/Mr.Elendig's xmonad.hs]] (0.7)<br />
; Somewhat simple, but verbose config, with ResizableTall, xmobar and mpd controlls.<br />
<br />
; [[/Marcot's xmonad.hs]] (darcs)<br />
; With Gnome support and Multimedia Keyboard configuration<br />
<br />
[[Image:Captura_da_tela.png|center|200px]]<br />
<br />
== Note on uploading ==<br />
<br />
To upload your config file, create some text on this page of the form:<br />
<br />
<nowiki>; [[/you Config.hs]]</nowiki><br />
<nowiki>: description of your setup</nowiki><br />
<br />
and save the page. This will create a new page under /you into which you<br />
can paste your Config.hs text. Wrap them in <nowiki><haskell></nowiki> and <nowiki></haskell></nowiki><br />
tags, to enable nice markup; add a nice category like <nowiki>[[Category:XMonad configuration]]</nowiki>, and upload. If you have an xmonad.hs for xmonad 0.5,<br />
upload that to<br />
<br />
<nowiki>; [[/you xmonad.hs]]</nowiki><br />
<br />
Images can be uploaded by clicking on the 'Upload file' link, and then<br />
referring to the uploaded image as, e.g.<br />
<br />
<nowiki>[[Image:you-config.png|center|200px]]</nowiki><br />
<br />
which will scale the image correctly for a thumbnail.<br />
<br />
[[Category:XMonad configuration]]</div>Marcothttps://wiki.haskell.org/index.php?title=File:Captura_da_tela.png&diff=21786File:Captura da tela.png2008-07-15T22:06:15Z<p>Marcot: XMonad with Marcot's xmonad.hs.</p>
<hr />
<div>XMonad with [[Marcot's xmonad.hs]].</div>Marcothttps://wiki.haskell.org/index.php?title=Xmonad/Config_archive/Marcot%27s_xmonad.hs&diff=21784Xmonad/Config archive/Marcot's xmonad.hs2008-07-15T21:27:32Z<p>Marcot: </p>
<hr />
<div><haskell><br />
{-# OPTIONS_GHC -cpp #-}<br />
<br />
{-<br />
#include <X11/XF86keysym.h><br />
-}<br />
<br />
import Data.Map hiding (keys, map)<br />
<br />
import XMonad<br />
<br />
import XMonad.Actions.PerWorkspaceKeys<br />
import XMonad.Config.Desktop<br />
import XMonad.Config.Gnome<br />
import XMonad.Hooks.EventHook<br />
import XMonad.Hooks.EwmhDesktops<br />
import XMonad.Hooks.ManageDocks hiding (Direction)<br />
import XMonad.Layout.LayoutModifier<br />
import XMonad.Layout.PerWorkspace<br />
<br />
main :: IO ()<br />
main =<br />
xmonad gnomeConfig<br />
{ workspaces = myWorkspaces<br />
, layoutHook = myLayoutHook<br />
, terminal = myTerminal<br />
, modMask = mod4Mask<br />
, keys = myKeys<br />
, manageHook = manageHook gnomeConfig <+> composeAll myManageHook<br />
}<br />
<br />
myWorkspaces :: [String]<br />
myWorkspaces =<br />
[ "conversa", "terminal", "correio"<br />
, "navegador", "editor", "noticias"<br />
, "documentos", "dinheiro", "musica"<br />
]<br />
<br />
myLayoutHook ::<br />
PerWorkspace<br />
(ModifiedLayout AvoidStruts (HandleEvent EwmhDesktopsHook (Choose Tall (Choose Full (Mirror Tall)))))<br />
(ModifiedLayout AvoidStruts (HandleEvent EwmhDesktopsHook (Choose Full (Choose Tall (Mirror Tall)))))<br />
a<br />
myLayoutHook =<br />
onWorkspace "conversa"<br />
(three (tiled (25 / 34)) Full mirror)<br />
$ three Full tiled2 mirror<br />
<br />
three<br />
:: (LayoutClass layout1 a, LayoutClass layout2 a, LayoutClass layout3 a)<br />
=> layout1 a -> layout2 a -> layout3 a<br />
-> ModifiedLayout AvoidStruts (HandleEvent EwmhDesktopsHook (Choose layout1 (Choose layout2 layout3))) a<br />
three first second third = desktopLayoutModifiers $ first ||| second ||| third<br />
<br />
tiled :: Rational -> Tall a<br />
tiled = Tall 1 (3 / 100)<br />
<br />
mirror :: Mirror Tall a<br />
mirror = Mirror tiled2<br />
<br />
tiled2 :: Tall a<br />
tiled2 = tiled $ 1 / 2<br />
<br />
myTerminal :: String<br />
myTerminal = "gnome-terminal -e screen"<br />
<br />
myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ())<br />
myKeys conf =<br />
let<br />
m :: KeyMask<br />
m = modMask conf<br />
<br />
mS :: KeyMask<br />
mS = m .|. shiftMask<br />
in<br />
union<br />
(<br />
fromList $<br />
[ ((mS, xK_Return), bindOn $ zip myWorkspaces workspaceBindings)<br />
, shortcut mS "gnome-power-cmd.sh shutdown" xK_s<br />
]<br />
++ multimedia<br />
)<br />
$ keys gnomeConfig conf<br />
<br />
workspaceBindings :: [X ()]<br />
workspaceBindings =<br />
[ spawn "pidgin", spawn myTerminal, spawn "evolution"<br />
, spawn "epiphany", spawn "emacs -r", spawn "liferea"<br />
, spawn "evince", spawn "gnucash", spawn "rhythmbox"<br />
]<br />
<br />
shortcut :: MonadIO x => keyMask -> String -> keySym -> ((keyMask, keySym), x ())<br />
shortcut keyMask command keySym = ((keyMask, keySym), spawn command)<br />
<br />
multimedia :: [((KeyMask, KeySym), X ())]<br />
multimedia =<br />
[ player "prev" XF86XK_AudioPrev<br />
, player "next" XF86XK_AudioNext<br />
, amixer "toggle" XF86XK_AudioMute<br />
, players "pause" "play-pause" XF86XK_AudioPlay<br />
, player "stop" XF86XK_AudioStop<br />
, volume '-' XF86XK_AudioLowerVolume<br />
, volume '+' XF86XK_AudioRaiseVolume<br />
, noMask "rhythmbox" XF86XK_Music<br />
]<br />
<br />
player :: String -> keySym -> ((KeyMask, keySym), X ())<br />
player command = players command command<br />
<br />
players :: String -> String -> keySym -> ((KeyMask, keySym), X ())<br />
players decibel rhythmbox =<br />
noMask $ "decibel-audio-player-remote " ++ decibel ++ "; rhythmbox-client --no-start --" ++ rhythmbox<br />
<br />
noMask :: String -> keySym -> ((KeyMask, keySym), X ())<br />
noMask = shortcut 0<br />
<br />
amixer :: String -> keySym -> ((KeyMask, keySym), X ())<br />
amixer option = noMask $ "amixer set PCM playback" ++ option<br />
<br />
volume :: Char -> keySym -> ((KeyMask, keySym), X ())<br />
volume signal = amixer $ "3dB" ++ [signal]<br />
<br />
myManageHook :: [ManageHook]<br />
myManageHook =<br />
[ associate "conversa" "Pidgin"<br />
, associate "terminal" "Gnome-terminal"<br />
, associate "correio" "Evolution"<br />
, associate "navegador" "Epiphany-browser"<br />
, associate "noticias" "Liferea-bin"<br />
, associate "documentos" "Evince"<br />
, editor "BrOffice.org 2.0"<br />
, editor "Emacs"<br />
, dinheiro "Gnucash"<br />
, dinheiro "Glade-3"<br />
, musica "Rhythmbox"<br />
, musica "Totem"<br />
, musica "Decibel-audio-player"<br />
, musica "Audacity"<br />
]<br />
<br />
associate :: WorkspaceId -> String -> ManageHook<br />
associate area wmClass = className =? wmClass --> doShift area<br />
<br />
editor :: String -> ManageHook<br />
editor = associate "editor"<br />
<br />
dinheiro :: String -> ManageHook<br />
dinheiro = associate "dinheiro"<br />
<br />
musica :: String -> ManageHook<br />
musica = associate "musica"<br />
</haskell></div>Marcothttps://wiki.haskell.org/index.php?title=Xmonad/Config_archive&diff=21783Xmonad/Config archive2008-07-15T21:26:28Z<p>Marcot: Marcot's xmonad.hs</p>
<hr />
<div>{{xmonad}}<br />
<br />
==xmonad configuration examples==<br />
<br />
Configuration files (Config.hs for xmonad < 0.5, xmonad.hs for xmonad >= 0.5)<br />
<br />
Many config files marked as 0.5 probably work in 0.6 as well; give it a try and ask on the #xmonad IRC channel on freenode.org if you have problems.<br />
<br />
For more screenshots see the [[Xmonad/Screenshots]] archive.<br />
<br />
;[[/Template xmonad.hs (0.7)]]<br />
;[[/Template xmonad.hs]] (0.6)<br />
:The default xmonad settings, in the form of a template, so you can easily edit and replace any values.<br />
<br />
;[[/Don's xmonad.hs]] (0.5,0.6,0.7)<br />
:[[/Don's Config.hs]] (0.4)<br />
:colours, use custom terminal, dynamicLogDzen<br />
[[Image:Xmonad-screen-dons-code.png|center|200px]]<br />
<br />
;[[/Gwern's Config.hs]] (0.7-; darcs)<br />
:[[/Gwern's Config.hs (0.4)]] (old)<br />
:Ratpoison-y keybindings; example usage of XSelection.<br />
<br />
;[[/twifkak's xmonad.hs]] (0.5)<br />
:[[/twifkak's Config.hs]] (0.4)<br />
:modMask = mod4Mask; noBorders tabbed layout; keybindings for dzen, rotview, swapworkspaces, windowbringer, and windownavigation; urgencyhook (only in darcs xmonad).<br />
<br />
;[[/nomeatas Config.hs]] (0.4)<br />
:modMaks = mod4Mask; gnome-stuff<br />
<br />
;[[/David Roundy's xmonad.hs]] (0.5)<br />
:Combo config for small screen + xclock. Requires the xmonad-library branch, so not for the faint of heart. This config also keeps mod=mod1, and therefore moves a number of key bindings to non-standard locations (my laptop has no spare modifier keys).<br />
[[Image:droundy-config.png|center|200px]]<br />
<br />
;[[/Brent Yorgey's xmonad.hs]] (0.6)<br />
:[[/Brent Yorgey's darcs xmonad.hs]] (darcs)<br />
:modMask = mod4Mask; DynamicLog, RotView, ViewPrev, WindowNavigation, ToggleLayouts (toggle full screen mode), UrgencyHook + dzen, FlexibleManipulate, a bunch of Prompts, Submap, Search, and a few others, with keybindings for all! (Warning: lots of non-standard keybindings. =)<br />
[[Image:byorgey-config.png|center|200px]]<br />
<br />
;[[/Robert Manea's xmonad.hs]] (0.5)<br />
:[[/Robert Manea's Config.hs and support scripts]] (0.4)<br />
:Customized DynamicLog and ShellPrompt, ManageDock, some efforts to make the colors of all components go together well<br />
0.4 screenshot: [[Image:rob-config.png|center|400px]]<br />
0.5 screenshot: [[Image:Xmonad_shellprompt_newconf.png|center|400px]]<br />
<br />
;[[/Eric Mertens' xmonad.hs]] (0.5)<br />
:[[/Eric Mertens's Config.hs]] (0.4)<br />
:Customized DynamicLog, ShellPrompt, TilePrime, Dual-head and an effort to make the statusbar similar to DWM.<br />
[[Image:glguy-config.jpg|center|400px]]<br />
<br />
;[[/vvv's xmonad.hs]] (0.5-0.7)<br />
:[[/vvv's Config.hs]] (0.4)<br />
:CustomKeys, CycleWS, {Shell,Ssh,Man}Prompt, Submap, DynamicWorkspaces, NoBorders, and ion-like status bar written in nonkosher Perl.<br />
[[Image:vvv-config.png|center|200px]]<br />
<br />
;[[/Andrea Rossato's xmonad.hs]] (0.5)<br />
:[[/arossato's Config.hs]] (0.4)<br />
:Tabbed, Xmobar with DynamicLog, (Shell|Ssh|Man)Prompt.<br />
[[Image:Arossato-config.png|center|200px]]<br />
<br />
;[[/Octoploid's xmonad.hs]] (0.7)<br />
:Xmobar with customized DynamicLog, CycleWS with custom keys, colors, terminal, golden ratio<br />
[[Image:Octoploid_conf.png|center|200px]]<br />
<br />
;[[/Ray's xmonad.hs]] (0.5)<br />
:DynamicLog, custom manageHook, changed from default terminal, border colors, prompts, and layouts. Pseudo-Haskell dzen statusbar with greek letters for workspace names.<br />
[[Image:Ray-config.png|center|200px]]<br />
<br />
;[[/nattfodd's xmonad.hs]] (0.7/darcs)<br />
:DynamicLog, smartBorders, French keyboard, defaultGap, urgencyHook in workspace toolbar and some prompts.<br />
[[Image:Nattfodd-xmonad-0.7.png|center|200px]]<br />
<br />
;[[/deifl's xmonad.hs]] (0.5)<br />
:DynamicLog, WindowBringer, CopyWindow, ResizableTile, Tabbed layout. not default terminal, changed colors and some instances of dzen.<br />
Clean: [[Image:D_xmonad_clear.jpg|center|200px]]<br />
Populated: [[Image:D_xmonad_full.jpg|center|200px]]<br />
<br />
;[[/Xilon's xmonad.hs]] (0.5)<br />
:Simple and clean setup with dzen and a tray. Dzen with workspaces uses UrgencyHook for Urgent windows.<br />
[[Image:xilon-config.png|center|200px]]<br />
<br />
; [[/skorpan's xmonad.hs]] (0.7)<br />
: Pretty clean setup. I use conky-cli with dzen2 at the bottom of the screenshot, which is not included here.<br />
[[Image:Skorpan.png|center|200px]]<br />
<br />
;[[/loupgaroublonds xmonad.hs]] (0.5)<br />
: mostly a stock config but with support for gnome and my cat<br />
[[Image:loupgaroublond-config.png|center|200px]]<br />
<br />
;[[/cce xmonad.hs]] (0.5)<br />
: alt+enter full screen, alt+hjkl to navigate, many remapped keys<br />
<br />
;[[/entropies xmonad.hs]] (0.5)<br />
: windows as meta key, fullscreen & noborders on keypress for client. custom keybindings. magnifier.<br />
[[Image:entropie-config.png|center|200px]]<br />
<br />
; [[/brad's xmonad.hs]] (0.7)<br />
: very basic, just some cosmetic and key-shortcut changes<br />
[[Image:brad.png|center|200px]]<br />
<br />
; [[/Lee Aylward's xmonad.hs]] (0.5)<br />
: Resizable Tall, NoBorders, dzen DynamicLog, rhythmbox control shortcuts, windows key<br />
[[Image:leeaylward.png|center|400px]]<br />
<br />
; [[/oxymor00n's xmonad.hs]] (darcs)<br />
: [[/oxymor00n's xmobarrc]]<br />
: Tabbed layout, Floating Layout, xmobar, EZConfig for Emacs-like keybinding-definition, added some bindings for the mouse wheel (cycle focus and cycle workspaces), cycleWS-stuff that might be interesting for Xinerama-users,...<br />
[[Image:oxymor00n-xmonad.png|center|200px]]<br />
<br />
<br />
; [[/Andrea Spada xmonad.hs]] (0.6)<br />
: Tall, Resizable Mosaic and Combo, EvmhDesktops, additional keybindings - Work In Progress...<br />
<br />
; [[/Wfarr's xmonad.hs]] (0.6/darcs)<br />
: ResizableTall Layout using EZConfig, cycleWS, CopyWindows, and DZen to get some cool stuff happening.<br />
[[Image:Wfarrscreen1.png|center|200px]]<br />
<br />
; [[/lithis's xmonad.hs]] (darcs)<br />
; [[/lithis's xmobarrc]] (darcs)<br />
: The screenshot shows xmobar, two screens, a spiral layout, a tabbed layout, XFT fonts, and ShellPrompt with tab completion. The config also has pointer follows focus.<br />
[[Image:lithis-xmonad.png|center|200px]]<br />
<br />
; [[/andrewsw's xmonad.hs]] (0.6)<br />
; [[/andrewsw's .Xdefault]]<br />
: These screenshots show some compositing and nice transparent urxvt's with a circle layout and a magnified grid layout.<br />
<br />
[[Image:Xmonad-circle-comp.jpg|center|200px]]<br />
[[Image:Xmonad-mag-grid.jpg|center|200px]]<br />
<br />
; [[/sykopomp's xmonad.hs]] (darcs)<br />
; [[/sykopomp's xmonad.dv-vi.hs]]<br />
; This screeshot shows xfce-panel with pager + xmonad in a ResizableTall layout. Also using compositing and transparent urxvt's (thanks andrewsw) with bindings for changing transparency on focused window. Keybindings have been completely redone to be more similar to emacs-bindings (M-p and M-n for previous and next windows). The other config is an older config that uses the standard vi-like bindings, but translated by location to a dvorak layout.<br />
[[Image:xmonad-screen-xinerama-composite-xfce.jpg|center|200px]]<br />
<br />
; [[/sphynx's xmonad.hs]] (darcs)<br />
; Emacs-style keybindings, xmobar integration, XFT-fonts, ManageDocks, Tabbed layout, IM layout for Pidgin and Skype configured through PerWorkspace, Search extension for wikipedia, translation and google, usage of CopyWindow to 'make window always visible', Urgency hook, PerWorkspace usage, Scratchpad terminal, custom styles for prompt and borders.<br />
<br />
; [[/thoughtpolice's xmonad.hs]] (darcs)<br />
; [[/thoughtpolice's xmobarrc]] (0.9)<br />
; Emacs-esque keyboard bindings via EZConfig, dynamicLog with dzen, Submap google/hoogle/amazon/imdb/youtube/wikipedia searching, Shell & Ssh modules, slightly custom XPConfig and avoidStruts (ManageDocks.)<br />
<br />
; [[/Remi's xmonad.hs]] (0.7)<br />
; [[/Remi's .xmobarrc]] (0.8)<br />
; [[/Remi's .xinitrc]]<br />
: Lots of key bindings for destkop-navigation/moving, xmonad.hs-editing, music, next-N-windows-float-hack. xmobar integration and PerWorkspace Layouts. And a yet-to-be-published libmpd xmobar plugin.<br />
<br />
[[Image:Remi-xmonad-screenshot.png|center|200px]]<br />
<br />
; [[/TeXitoi's xmonad.hs]] (0.7)<br />
; French keyboard, ManageDock, EwmhDesktops. Minimal configuration file with Defaults not overwritten. Mist GTK theme is used.<br />
<br />
[[Image:Xmonad-xfce-panel.png|center|200px]]<br />
<br />
; [[/Mr.Elendig's xmonad.hs]] (0.7)<br />
; Somewhat simple, but verbose config, with ResizableTall, xmobar and mpd controlls.<br />
<br />
; [[/Marcot's xmonad.hs]] (darcs)<br />
; With Gnome support and Multimedia Keyboard configuration<br />
<br />
== Note on uploading ==<br />
<br />
To upload your config file, create some text on this page of the form:<br />
<br />
<nowiki>; [[/you Config.hs]]</nowiki><br />
<nowiki>: description of your setup</nowiki><br />
<br />
and save the page. This will create a new page under /you into which you<br />
can paste your Config.hs text. Wrap them in <nowiki><haskell></nowiki> and <nowiki></haskell></nowiki><br />
tags, to enable nice markup; add a nice category like <nowiki>[[Category:XMonad configuration]]</nowiki>, and upload. If you have an xmonad.hs for xmonad 0.5,<br />
upload that to<br />
<br />
<nowiki>; [[/you xmonad.hs]]</nowiki><br />
<br />
Images can be uploaded by clicking on the 'Upload file' link, and then<br />
referring to the uploaded image as, e.g.<br />
<br />
<nowiki>[[Image:you-config.png|center|200px]]</nowiki><br />
<br />
which will scale the image correctly for a thumbnail.<br />
<br />
[[Category:XMonad configuration]]</div>Marcot