mirror of
https://github.com/xmonad/xmonad.git
synced 2025-05-19 00:20:22 -07:00
Add --restart, a command line flag to cause a running xmonad process to restart
This commit is contained in:
parent
5edfb1d262
commit
bf8ba79090
13
Main.hs
13
Main.hs
@ -40,6 +40,7 @@ main = do
|
|||||||
["--resume", _] -> launch
|
["--resume", _] -> launch
|
||||||
["--help"] -> usage
|
["--help"] -> usage
|
||||||
["--recompile"] -> recompile True >> return ()
|
["--recompile"] -> recompile True >> return ()
|
||||||
|
["--restart"] -> sendRestart >> return ()
|
||||||
["--version"] -> putStrLn ("xmonad " ++ showVersion version)
|
["--version"] -> putStrLn ("xmonad " ++ showVersion version)
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
("--run-tests":_) -> Properties.main
|
("--run-tests":_) -> Properties.main
|
||||||
@ -55,6 +56,7 @@ usage = do
|
|||||||
" --help Print this message" :
|
" --help Print this message" :
|
||||||
" --version Print the version number" :
|
" --version Print the version number" :
|
||||||
" --recompile Recompile your ~/.xmonad/xmonad.hs" :
|
" --recompile Recompile your ~/.xmonad/xmonad.hs" :
|
||||||
|
" --restart Request a running xmonad process to restart" :
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
" --run-tests Run the test suite" :
|
" --run-tests Run the test suite" :
|
||||||
#endif
|
#endif
|
||||||
@ -83,3 +85,14 @@ buildLaunch = do
|
|||||||
args <- getArgs
|
args <- getArgs
|
||||||
executeFile (dir ++ "/xmonad-"++arch++"-"++os) False args Nothing
|
executeFile (dir ++ "/xmonad-"++arch++"-"++os) False args Nothing
|
||||||
return ()
|
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
|
||||||
|
@ -280,6 +280,12 @@ handle (ConfigureEvent {ev_window = w}) = whenX (isRoot w) rescreen
|
|||||||
handle PropertyEvent { ev_event_type = t, ev_atom = a }
|
handle PropertyEvent { ev_event_type = t, ev_atom = a }
|
||||||
| t == propertyNotify && a == wM_NAME = userCodeDef () =<< asks (logHook . config)
|
| 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
|
handle e = broadcastMessage e -- trace (eventName e) -- ignoring
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ When running with multiple monitors (Xinerama), each screen has exactly 1 worksp
|
|||||||
.TP
|
.TP
|
||||||
\fB--recompile
|
\fB--recompile
|
||||||
Recompiles your configuration in ~/.xmonad/xmonad.hs
|
Recompiles your configuration in ~/.xmonad/xmonad.hs
|
||||||
|
\fB--restart
|
||||||
|
Causes the currently running xmonad process to restart
|
||||||
.TP
|
.TP
|
||||||
\fB--version
|
\fB--version
|
||||||
Display version of \fBxmonad\fR.
|
Display version of \fBxmonad\fR.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user