----------------------------------------------------------------------------- -- | -- Module : Main -- Copyright : (c) Andrea Rossato -- License : GPL2 -- -- Maintainer : Andrea Rossato -- Stability : unstable -- Portability : unportable -- -- Toggle override_redirect for an X window -- ----------------------------------------------------------------------------- module Main where import Graphics.X11.Xlib import Graphics.X11.Xlib.Extras import System.Environment import Control.Monad usage :: String -> String usage n = "Usage: " ++ n ++ " windowID command" main :: IO () main = do args <- getArgs pn <- getProgName let com = case args of [] -> error $ usage pn w -> (w !! 0) dpy <- openDisplay "" rootw <- rootWindow dpy $ defaultScreen dpy (_,_, ws) <- queryTree dpy rootw [win] <- filterM (\w -> do s <- getClassHint dpy w n <- maybe (resName s) id `fmap` (fetchName dpy w) if n == "ServerWindow" then return True else return False) ws setTextProperty dpy win com wM_COMMAND allocaXEvent $ \e -> do setEventType e propertyNotify putStrLn $ show win sendEvent dpy win False noEventMask e sync dpy False