summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrent Yorgey <byorgey@gmail.com>2008-02-04 20:24:45 +0100
committerBrent Yorgey <byorgey@gmail.com>2008-02-04 20:24:45 +0100
commitd81c930991f6229fba9c6ae015b68d411ce594af (patch)
treefc7aa74ccbcb47b52a2811da0ef88235637cae2b
parent27777de6f100ab09b8df2f50323b0b22fb2f4afc (diff)
downloadmetatile-d81c930991f6229fba9c6ae015b68d411ce594af.tar
metatile-d81c930991f6229fba9c6ae015b68d411ce594af.zip
Add a startupHook.
The only thing I am not sure about here is at what exact point the startupHook should get run. I picked a place that seems to make sense: as late as possible, right before entering the main loop. That way all the layouts/workspaces/other state are set up and the startupHook can manipulate them. darcs-hash:20080204192445-bd4d7-218d69dcf3cd5c5f2962859cf847595527399807
-rw-r--r--XMonad/Config.hs9
-rw-r--r--XMonad/Core.hs1
-rw-r--r--XMonad/Main.hs2
-rw-r--r--man/xmonad.hs13
4 files changed, 22 insertions, 3 deletions
diff --git a/XMonad/Config.hs b/XMonad/Config.hs
index 677248d..98ec02a 100644
--- a/XMonad/Config.hs
+++ b/XMonad/Config.hs
@@ -25,11 +25,11 @@ module XMonad.Config (defaultConfig) where
-- Useful imports
--
import XMonad.Core as XMonad hiding
- (workspaces,manageHook,numlockMask,keys,logHook,borderWidth,mouseBindings
+ (workspaces,manageHook,numlockMask,keys,logHook,startupHook,borderWidth,mouseBindings
,defaultGaps,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor
,focusFollowsMouse)
import qualified XMonad.Core as XMonad
- (workspaces,manageHook,numlockMask,keys,logHook,borderWidth,mouseBindings
+ (workspaces,manageHook,numlockMask,keys,logHook,startupHook,borderWidth,mouseBindings
,defaultGaps,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor
,focusFollowsMouse)
@@ -134,6 +134,10 @@ manageHook = composeAll
logHook :: X ()
logHook = return ()
+-- | Perform an arbitrary action at xmonad startup.
+startupHook :: X ()
+startupHook = return ()
+
------------------------------------------------------------------------
-- Extensible layouts
--
@@ -256,6 +260,7 @@ defaultConfig = XConfig
, XMonad.modMask = defaultModMask
, XMonad.keys = keys
, XMonad.logHook = logHook
+ , XMonad.startupHook = startupHook
, XMonad.mouseBindings = mouseBindings
, XMonad.manageHook = manageHook
, XMonad.focusFollowsMouse = focusFollowsMouse }
diff --git a/XMonad/Core.hs b/XMonad/Core.hs
index ea84bd6..89e6ab2 100644
--- a/XMonad/Core.hs
+++ b/XMonad/Core.hs
@@ -88,6 +88,7 @@ data XConfig l = XConfig
-- ^ The mouse bindings
, borderWidth :: !Dimension -- ^ The border width
, logHook :: !(X ()) -- ^ The action to perform when the windows set is changed
+ , startupHook :: !(X ()) -- ^ The action to perform on startup
, focusFollowsMouse :: !Bool -- ^ Whether window entry events can change focus
}
diff --git a/XMonad/Main.hs b/XMonad/Main.hs
index 7557ad6..405caec 100644
--- a/XMonad/Main.hs
+++ b/XMonad/Main.hs
@@ -116,6 +116,8 @@ xmonad initxmc = do
-- manage the as-yet-unmanaged windows
mapM_ manage (ws \\ W.allWindows winset)
+ startupHook initxmc
+
-- main loop, for all you HOF/recursion fans out there.
forever_ $ handle =<< io (nextEvent dpy e >> getEvent e)
diff --git a/man/xmonad.hs b/man/xmonad.hs
index e283afb..5858e36 100644
--- a/man/xmonad.hs
+++ b/man/xmonad.hs
@@ -248,6 +248,16 @@ myFocusFollowsMouse = True
myLogHook = return ()
------------------------------------------------------------------------
+-- Startup hook
+
+-- Perform an arbitrary action each time xmonad starts or is restarted
+-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
+-- per-workspace layout choices.
+--
+-- By default, do nothing.
+myStartupHook = return ()
+
+------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
-- Run xmonad with the settings you specify. No need to modify this.
@@ -279,5 +289,6 @@ defaults = defaultConfig {
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook,
- logHook = myLogHook
+ logHook = myLogHook,
+ startupHook = myStartupHook
}