From fd1241fdc5f3ce8c6f74d607ba82827c9ac603fe Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Sat, 7 Nov 2009 01:48:58 +0100 Subject: Add xmonadpropread script Ignore-this: 8cc7ed36ec1126d0139638148f9642e8 darcs-hash:20091107004858-25a6b-098a5d757d5eff237eee1b2cef4c3893059d1248.gz --- scripts/xmonadpropread.hs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/xmonadpropread.hs (limited to 'scripts') diff --git a/scripts/xmonadpropread.hs b/scripts/xmonadpropread.hs new file mode 100644 index 0000000..88049f2 --- /dev/null +++ b/scripts/xmonadpropread.hs @@ -0,0 +1,31 @@ +-- Copyright Spencer Janssen +-- BSD3 (see LICENSE) +-- +-- Experimental, will add proper documentation later (famous last words) + +import Control.Monad +import Graphics.X11 +import Graphics.X11.Xlib.Extras +import Codec.Binary.UTF8.String as UTF8 +import Foreign.C (CChar) + +main = do + d <- openDisplay "" + xlog <- internAtom d "_XMONAD_LOG" False + + root <- rootWindow d (defaultScreen d) + selectInput d root propertyChangeMask + + allocaXEvent $ \ep -> forever $ do + nextEvent d ep + e <- getEvent ep + case e of + PropertyEvent { ev_atom = a } | a == xlog -> do + mwp <- getWindowProperty8 d xlog root + maybe (return ()) (putStrLn . decodeCChar) mwp + _ -> return () + + return () + +decodeCChar :: [CChar] -> String +decodeCChar = UTF8.decode . map fromIntegral -- cgit v1.2.3