summaryrefslogtreecommitdiff
path: root/desktop/xmonad
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2013-08-20 09:06:12 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2013-08-20 09:06:12 +0100
commit6fcb081b5c727356b56e78283a12b6bb9e0207a9 (patch)
treecb6a759601f8de33b8b57a7c1a51ae3f6d0a87f6 /desktop/xmonad
parent215b880dae5880793c2167fc9ee64a1d5c22a132 (diff)
downloadresources-6fcb081b5c727356b56e78283a12b6bb9e0207a9.tar.bz2
Do a better job of detecting screen changes
Diffstat (limited to 'desktop/xmonad')
-rw-r--r--desktop/xmonad/xmonad.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/desktop/xmonad/xmonad.hs b/desktop/xmonad/xmonad.hs
index 9aa3b06..f7f6b21 100644
--- a/desktop/xmonad/xmonad.hs
+++ b/desktop/xmonad/xmonad.hs
@@ -68,9 +68,9 @@ instance ExtensionClass ScreenTracker where
initialValue = ScreenTracker { stScreenCount = 0 }
extensionType = PersistentExtension
-myStartupHook :: X ()
-myStartupHook = do
- liftIO $ putStrLn "Starting up XMonad..."
+myScreenChangeHook :: X ()
+myScreenChangeHook = do
+ liftIO $ putStrLn "Examining screen count..."
st <- XS.get
let count = stScreenCount st
nowCount <- countScreens
@@ -79,11 +79,16 @@ myStartupHook = do
else do
XS.put $ st { stScreenCount = nowCount }
liftIO $ putStrLn $ "Changed from " ++ (show count) ++ " to " ++ (show nowCount)
- if (count /= 0)
+ if (nowCount > 1)
then safeSpawn "gnome-control-center" ["display"]
- else return ()
+ else liftIO $ putStrLn "Not doing anything, nowCount < 2"
- liftIO $ putStrLn "Startup hook completed."
+ liftIO $ putStrLn "Screen count examined."
+
+myEventHandler :: (Event -> X a) -> Event -> X a
+myEventHandler h e@(ConfigureEvent {ev_window = w}) =
+ (whenX (isRoot w) myScreenChangeHook) >> h e
+myEventHandler h e = h e
main :: IO ()
main = do
@@ -94,13 +99,12 @@ main = do
, logHook = myLogHook client pp
, manageHook = myManageHook <+> manageHook gnomeConfig
, workspaces = defaultWorkSpaces
- , handleEventHook = fullscreenEventHook
+ , handleEventHook = myEventHandler fullscreenEventHook
, layoutHook = id
. smartBorders
. minimize
. mkToggle (single FULL)
$ (layoutHook gnomeConfig)
- , startupHook = myStartupHook
} `EZ.additionalKeysP`
[ -- General keys
("M-x", spawn "gnome-terminal")