Advertisement
Guest User

Untitled

a guest
May 5th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/runhaskell
  2. import Graphics.X11.Xlib
  3. import Graphics.X11.Xlib.Extras
  4. import System.Environment
  5.  
  6. usage :: String -> String
  7. usage n = "Usage: " ++ n ++ " command number\nSend a command number to a running instance of XMonad"
  8. main :: IO ()
  9. main = do
  10. args <- getArgs
  11. pn <- getProgName
  12. let com = case args of
  13. [] -> error $ usage pn
  14. w -> head w
  15. sendCommand com
  16. sendCommand :: String -> IO ()
  17. sendCommand s = do
  18. d <- openDisplay ""
  19. rw <- rootWindow d $ defaultScreen d
  20. a <- internAtom d "XMONAD_COMMAND" False
  21. allocaXEvent $ \e -> do
  22. setEventType e clientMessage
  23. setClientMessageEvent e rw a 32 (fromIntegral (read s :: Int)) currentTime
  24. sendEvent d rw False structureNotifyMask e
  25. sync d False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement