summaryrefslogtreecommitdiff
path: root/sendCommand.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-02-16 17:59:03 +0000
committerjao <jao@gnu.org>2022-02-16 17:59:03 +0000
commit0f67011c139348ebab63c9c01e7d8f19744d6d12 (patch)
tree5cfcfbed515e5190cb03ca64b7eb7f0f809b1b0f /sendCommand.hs
downloadxmonad-config-0f67011c139348ebab63c9c01e7d8f19744d6d12.tar.gz
xmonad-config-0f67011c139348ebab63c9c01e7d8f19744d6d12.tar.bz2
initial contents
Diffstat (limited to 'sendCommand.hs')
-rw-r--r--sendCommand.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/sendCommand.hs b/sendCommand.hs
new file mode 100644
index 0000000..635f729
--- /dev/null
+++ b/sendCommand.hs
@@ -0,0 +1,21 @@
+-- https://gist.github.com/lierdakil/216a9d2b9e934d9e1a30
+
+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 ()