aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <spencerjanssen@gmail.com>2009-01-17 04:49:59 +0100
committerSpencer Janssen <spencerjanssen@gmail.com>2009-01-17 04:49:59 +0100
commit68e608ccff6a880650421e1fa99b60239ba42b59 (patch)
tree173e1553bbe2a875c1e90fa50d6c9fe32f1c5554
parentba7c1d66d1e68aa75cd33426ed2078e050d762cd (diff)
downloadxmonad-68e608ccff6a880650421e1fa99b60239ba42b59.tar.gz
xmonad-68e608ccff6a880650421e1fa99b60239ba42b59.tar.xz
xmonad-68e608ccff6a880650421e1fa99b60239ba42b59.zip
Add --restart, a command line flag to cause a running xmonad process to restart
Ignore-this: 45c8c8aba7cc7391b95c7e3fb01e5bf9 darcs-hash:20090117034959-25a6b-794fb65d26a59f6ca34b16538c35dc3c266ced7d.gz
-rw-r--r--Main.hs13
-rw-r--r--XMonad/Main.hsc6
-rw-r--r--man/xmonad.1.in2
3 files changed, 21 insertions, 0 deletions
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
diff --git a/XMonad/Main.hsc b/XMonad/Main.hsc
index 99bc77f..27295ba 100644
--- a/XMonad/Main.hsc
+++ b/XMonad/Main.hsc
@@ -280,6 +280,12 @@ handle (ConfigureEvent {ev_window = w}) = whenX (isRoot w) rescreen
handle PropertyEvent { ev_event_type = t, ev_atom = a }
| t == propertyNotify && a == wM_NAME = userCodeDef () =<< asks (logHook . config)
+handle e@ClientMessageEvent { ev_message_type = mt } = do
+ a <- getAtom "XMONAD_RESTART"
+ if (mt == a)
+ then restart "xmonad" True
+ else broadcastMessage e
+
handle e = broadcastMessage e -- trace (eventName e) -- ignoring
diff --git a/man/xmonad.1.in b/man/xmonad.1.in
index 922a7f1..33cf975 100644
--- a/man/xmonad.1.in
+++ b/man/xmonad.1.in
@@ -23,6 +23,8 @@ When running with multiple monitors (Xinerama), each screen has exactly 1 worksp
.TP
\fB--recompile
Recompiles your configuration in ~/.xmonad/xmonad.hs
+\fB--restart
+Causes the currently running xmonad process to restart
.TP
\fB--version
Display version of \fBxmonad\fR.