Skip to content

Instantly share code, notes, and snippets.

@lierdakil
Last active June 4, 2018 19:17
Show Gist options
  • Save lierdakil/216a9d2b9e934d9e1a30 to your computer and use it in GitHub Desktop.
Save lierdakil/216a9d2b9e934d9e1a30 to your computer and use it in GitHub Desktop.
Xmonad client for external control.
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras
import System.Environment
main :: IO ()
main = sendCommand "XMONAD_COMMAND" =<< getArgs
sendCommand :: String -> [String] -> IO ()
sendCommand addr (s:_) = do
d <- openDisplay ""
rw <- rootWindow d $ defaultScreen d
a <- internAtom d addr False
m <- internAtom d s False
allocaXEvent $ \e -> do
setEventType e clientMessage
setClientMessageEvent e rw a 32 m currentTime
sendEvent d rw False structureNotifyMask e
sync d False
sendCommand _ _ = return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment