Написал прибивалку SIGSTOP'ом firefox при переключении на другой воркспейс. Довольно криво, но работает. Очень актуально.
--{{{ Fuck firefox
myLogHook = do
wsname <- gets (currentTag . windowset)
case wsname of
"web" -> fuckFirefox False
_ -> fuckFirefox True
fuckFirefox ye = liftIO $ do
(rc, out, ) <- readProcessWithExitCode' "pgrep" ["firefox"] []
mapM fuckIt $ lines $ out
where fuckIt s = signalProcess (if ye then sigSTOP else sigCONT) (CPid $ read s)
readProcessWithExitCode'
:: FilePath -- ^ command to run
-> [String] -- ^ any arguments
-> String -- ^ standard input
-> IO (ExitCode,String,String) -- ^ exitcode, stdout, stderr
readProcessWithExitCode' cmd args input = do
(Just inh, Just outh, Just errh, pid) <-
createProcess (proc cmd args){ std_in = CreatePipe,
std_out = CreatePipe,
std_err = CreatePipe }
outMVar <- newEmptyMVar
-- fork off a thread to start consuming stdout
out <- hGetContents outh
forkIO $ C.evaluate (length out) >> putMVar outMVar ()
-- fork off a thread to start consuming stderr
err <- hGetContents errh
forkIO $ C.evaluate (length err) >> putMVar outMVar ()
-- now write and flush any input
when (not (null input)) $ do hPutStr inh input; hFlush inh
hClose inh -- done with stdin
-- wait on the output
takeMVar outMVar
takeMVar outMVar
hClose outh
-- wait on the process
ex <- C.catch (waitForProcess pid >>= return) (\e -> seq (e :: C.SomeException) $ return $ ExitSuccess)
return (ex, out, err)
--}}}
Хочу плагин для xmonad, суть такова: при переключении с/на воркспейс с прыщелисом или конки оный ловит SIGSTOP/SIGCONT.