summaryrefslogtreecommitdiffhomepage
path: root/samples/xmonadpropwrite.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-11-25 15:26:44 +0000
committerjao <jao@gnu.org>2018-11-25 15:26:44 +0000
commitf86bbb8ca5d3ba0d18e333cbe6cb57cc17e3ae07 (patch)
treeba34733d783dfcb65234ed835deac13a9a9c100e /samples/xmonadpropwrite.hs
parentb12fe3ebdaf3a4a539b85f742a582925d7e811f1 (diff)
downloadxmobar-f86bbb8ca5d3ba0d18e333cbe6cb57cc17e3ae07.tar.gz
xmobar-f86bbb8ca5d3ba0d18e333cbe6cb57cc17e3ae07.tar.bz2
doc, examples
Diffstat (limited to 'samples/xmonadpropwrite.hs')
-rw-r--r--samples/xmonadpropwrite.hs41
1 files changed, 0 insertions, 41 deletions
diff --git a/samples/xmonadpropwrite.hs b/samples/xmonadpropwrite.hs
deleted file mode 100644
index f3f4a5d..0000000
--- a/samples/xmonadpropwrite.hs
+++ /dev/null
@@ -1,41 +0,0 @@
--- Copyright Spencer Janssen <spencerjanssen@gmail.com>
--- Tomas Janousek <tomi@nomi.cz>
--- BSD3 (see LICENSE)
---
--- Reads from standard input and writes to an X propery on root window.
--- To be used with XPropertyLog:
--- Add it to commands:
--- Run XPropertyLog "_XMONAD_LOG_CUSTOM"
--- Add it to the template:
--- template = "... %_XMONAD_LOG_CUSTOM% ..."
--- Run:
--- $ blah blah | xmonadpropwrite _XMONAD_LOG_CUSTOM
-
-import Control.Monad
-import Graphics.X11
-import Graphics.X11.Xlib.Extras
-import qualified Data.ByteString as B
-import Foreign.C (CChar)
-import System.IO
-import System.Environment
-
-main = do
- atom <- flip fmap getArgs $ \args -> case args of
- [a] -> a
- _ -> "_XMONAD_LOG"
-
- d <- openDisplay ""
- xlog <- internAtom d atom False
- ustring <- internAtom d "UTF8_STRING" False
-
- root <- rootWindow d (defaultScreen d)
-
- forever $ do
- msg <- B.getLine
- changeProperty8 d root xlog ustring propModeReplace (encodeCChar msg)
- sync d True
-
- return ()
-
-encodeCChar :: B.ByteString -> [CChar]
-encodeCChar = map fromIntegral . B.unpack