aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schoepe <daniel.schoepe@gmail.com>2009-08-25 12:16:30 +0200
committerDaniel Schoepe <daniel.schoepe@gmail.com>2009-08-25 12:16:30 +0200
commitee8a7942eea59cae30df953d70a523f3bf1f0323 (patch)
tree6fd5374f6550c97c5fc36cd0264c917bed91db2c
parent34d6544fc247f12bb0cda0cc5da27a37d2d4b4bd (diff)
downloadXMonadContrib-ee8a7942eea59cae30df953d70a523f3bf1f0323.tar.gz
XMonadContrib-ee8a7942eea59cae30df953d70a523f3bf1f0323.tar.xz
XMonadContrib-ee8a7942eea59cae30df953d70a523f3bf1f0323.zip
Let the user decide which commands to use in X.H.ServerMode
Ignore-this: 3a1b95f85253ce6059f4528e23c5a3d3 darcs-hash:20090825101630-7f603-100cf20462e6cb4214e0737223f1b9141091f1b5.gz
-rw-r--r--XMonad/Config/Arossato.hs3
-rw-r--r--XMonad/Hooks/ServerMode.hs13
2 files changed, 10 insertions, 6 deletions
diff --git a/XMonad/Config/Arossato.hs b/XMonad/Config/Arossato.hs
index 4aa0087..c1cbd75 100644
--- a/XMonad/Config/Arossato.hs
+++ b/XMonad/Config/Arossato.hs
@@ -24,6 +24,7 @@ import qualified Data.Map as M
import XMonad hiding ( (|||) )
import qualified XMonad.StackSet as W
+import XMonad.Actions.Commands
import XMonad.Actions.CycleWS
import XMonad.Hooks.DynamicLog hiding (xmobar)
import XMonad.Hooks.ManageDocks
@@ -98,7 +99,7 @@ arossatoConfig = do
, normalBorderColor = "white"
, focusedBorderColor = "black"
, keys = newKeys
- , handleEventHook = serverModeEventHook
+ , handleEventHook = serverModeEventHook defaultCommands
, focusFollowsMouse = False
}
where
diff --git a/XMonad/Hooks/ServerMode.hs b/XMonad/Hooks/ServerMode.hs
index 66e3943..cb99831 100644
--- a/XMonad/Hooks/ServerMode.hs
+++ b/XMonad/Hooks/ServerMode.hs
@@ -75,23 +75,26 @@ import XMonad.Actions.Commands
-- @~\/.xmonad\/xmonad.hs@:
--
-- > import XMonad.Hooks.ServerMode
+-- > import XMonad.Actions.Commands
--
-- Then edit your @handleEventHook@ by adding the 'serverModeEventHook':
--
--- > main = xmonad defaultConfig { handleEventHook = serverModeEventHook }
+-- > main = xmonad defaultConfig { handleEventHook = serverModeEventHook defaultCommands }
--
data ServerMode = ServerMode deriving ( Show, Read )
-serverModeEventHook :: Event -> X All
-serverModeEventHook (ClientMessageEvent {ev_message_type = mt, ev_data = dt}) = do
+-- | Executes a command of the list when receiving its index via a special ClientMessageEvent
+-- (indexing starts at 1)
+serverModeEventHook :: X [(String,X ())] -> Event -> X All
+serverModeEventHook cmdAction (ClientMessageEvent {ev_message_type = mt, ev_data = dt}) = do
d <- asks display
a <- io $ internAtom d "XMONAD_COMMAND" False
when (mt == a && dt /= []) $ do
- cl <- defaultCommands
+ cl <- cmdAction
let listOfCommands = map (uncurry (++)) . zip (map show ([1..] :: [Int])) . map ((++) " - " . fst)
case lookup (fromIntegral (head dt) :: Int) (zip [1..] cl) of
Just (c,_) -> runCommand' c
Nothing -> mapM_ (io . hPutStrLn stderr) . listOfCommands $ cl
return (All True)
-serverModeEventHook _ = return (All True)
+serverModeEventHook _ _ = return (All True)