Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 420a649e6f65db30aa7451f64d08ff92 > files > 624

ghc-xmonad-contrib-devel-0.9.2-4.fc16.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>XMonad.Hooks.ServerMode</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_XMonad-Hooks-ServerMode.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/XMonad-Hooks-ServerMode.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">xmonad-contrib-0.9.2: Third party extensions for xmonad</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>unportable</td></tr><tr><th>Stability</th><td>unstable</td></tr><tr><th>Maintainer</th><td>andrea.rossato@unibz.it</td></tr></table><p class="caption">XMonad.Hooks.ServerMode</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Usage
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This is an <code>EventHook</code> that will receive commands from an external
 client.
</p><p>This is the example of a client:
</p><pre> import Graphics.X11.Xlib
 import Graphics.X11.Xlib.Extras
 import System.Environment
 import Data.Char

 usage :: String -&gt; String
 usage n = &quot;Usage: &quot; ++ n ++ &quot; command number\nSend a command number to a running instance of XMonad&quot;

 main :: IO ()
 main = do
   args &lt;- getArgs
   pn &lt;- getProgName
   let com = case args of
               [] -&gt; error $ usage pn
               w -&gt; (w !! 0)
   sendCommand com

 sendCommand :: String -&gt; IO ()
 sendCommand s = do
   d   &lt;- openDisplay &quot;&quot;
   rw  &lt;- rootWindow d $ defaultScreen d
   a &lt;- internAtom d &quot;XMONAD_COMMAND&quot; False
   allocaXEvent $ \e -&gt; do
                   setEventType e clientMessage
                   setClientMessageEvent e rw a 32 (fromIntegral (read s)) currentTime
                   sendEvent d rw False structureNotifyMask e
                   sync d False
</pre><p>compile with: <code>ghc --make sendCommand.hs</code>
</p><p>run with
</p><pre> sendCommand command number
</pre><p>For instance:
</p><pre> sendCommand 0
</pre><p>will ask to xmonad to print the list of command numbers in
 stderr (so you can read it in <code>~/.xsession-errors</code>).
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span>  <a href="#t:ServerMode">ServerMode</a>  = <a href="#v:ServerMode">ServerMode</a></li><li class="src short"><a href="#v:serverModeEventHook">serverModeEventHook</a> :: <a href="/usr/share/doc/ghc/html/libraries/X11-1.5.0.0/Graphics-X11-Xlib-Extras.html#t:Event">Event</a> -&gt; X <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Monoid.html#t:All">All</a></li><li class="src short"><a href="#v:serverModeEventHook-39-">serverModeEventHook'</a> :: X [(<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>, X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a>)] -&gt; <a href="/usr/share/doc/ghc/html/libraries/X11-1.5.0.0/Graphics-X11-Xlib-Extras.html#t:Event">Event</a> -&gt; X <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Monoid.html#t:All">All</a></li></ul></div><div id="interface"><h1 id="g:1">Usage
</h1><div class="doc"><p>You can use this module with the following in your
 <code>~/.xmonad/xmonad.hs</code>:
</p><pre> import XMonad.Hooks.ServerMode
 import XMonad.Actions.Commands
</pre><p>Then edit your <code>handleEventHook</code> by adding the <code><a href="XMonad-Hooks-ServerMode.html#v:serverModeEventHook">serverModeEventHook</a></code>:
</p><pre> main = xmonad defaultConfig { handleEventHook = serverModeEventHook }
</pre></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:ServerMode" class="def">ServerMode</a>  <a href="src/XMonad-Hooks-ServerMode.html#ServerMode" class="link">Source</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:ServerMode" class="def">ServerMode</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:ServerMode" class="caption collapser" onclick="toggleSection('i:ServerMode')">Instances</p><div id="section.i:ServerMode" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Read.html#t:Read">Read</a> <a href="XMonad-Hooks-ServerMode.html#t:ServerMode">ServerMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="XMonad-Hooks-ServerMode.html#t:ServerMode">ServerMode</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:serverModeEventHook" class="def">serverModeEventHook</a> :: <a href="/usr/share/doc/ghc/html/libraries/X11-1.5.0.0/Graphics-X11-Xlib-Extras.html#t:Event">Event</a> -&gt; X <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Monoid.html#t:All">All</a><a href="src/XMonad-Hooks-ServerMode.html#serverModeEventHook" class="link">Source</a></p><div class="doc"><p>Executes a command of the list when receiving its index via a special ClientMessageEvent
 (indexing starts at 1)
</p></div></div><div class="top"><p class="src"><a name="v:serverModeEventHook-39-" class="def">serverModeEventHook'</a> :: X [(<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>, X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a>)] -&gt; <a href="/usr/share/doc/ghc/html/libraries/X11-1.5.0.0/Graphics-X11-Xlib-Extras.html#t:Event">Event</a> -&gt; X <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Monoid.html#t:All">All</a><a href="src/XMonad-Hooks-ServerMode.html#serverModeEventHook%27" class="link">Source</a></p><div class="doc"><p>serverModeEventHook' additionally takes an action to generate the list of
 commands.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>