From d200a1bb6dda29222ab948c2b8d8d69139cbd31e Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Sat, 17 Jan 2009 04:49:59 +0100 Subject: Add --restart, a command line flag to cause a running xmonad process to restart Ignore-this: 45c8c8aba7cc7391b95c7e3fb01e5bf9 darcs-hash:20090117034959-25a6b-794fb65d26a59f6ca34b16538c35dc3c266ced7d --- Main.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 29ae822..d99b381 100644 --- a/Main.hs +++ b/Main.hs @@ -40,6 +40,7 @@ main = do ["--resume", _] -> launch ["--help"] -> usage ["--recompile"] -> recompile True >> return () + ["--restart"] -> sendRestart >> return () ["--version"] -> putStrLn ("xmonad " ++ showVersion version) #ifdef TESTING ("--run-tests":_) -> Properties.main @@ -55,6 +56,7 @@ usage = do " --help Print this message" : " --version Print the version number" : " --recompile Recompile your ~/.xmonad/xmonad.hs" : + " --restart Request a running xmonad process to restart" : #ifdef TESTING " --run-tests Run the test suite" : #endif @@ -83,3 +85,14 @@ buildLaunch = do args <- getArgs executeFile (dir ++ "/xmonad-"++arch++"-"++os) False args Nothing return () + +sendRestart :: IO () +sendRestart = do + dpy <- openDisplay "" + rw <- rootWindow dpy $ defaultScreen dpy + xmonad_restart <- internAtom dpy "XMONAD_RESTART" False + allocaXEvent $ \e -> do + setEventType e clientMessage + setClientMessageEvent e rw xmonad_restart 32 0 currentTime + sendEvent dpy rw False structureNotifyMask e + sync dpy False -- cgit v1.2.3