summaryrefslogtreecommitdiffhomepage
path: root/examples/xmonadpropwrite.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-08-09 23:48:44 +0100
committerjao <jao@gnu.org>2022-08-09 23:48:44 +0100
commit63303977071f34d8142709960e8dae97cea1951e (patch)
tree19ea7c2704548f64d01619d9418581156f35dea9 /examples/xmonadpropwrite.hs
parent474a7ebbe2589ae6b03f13c8318f36e9d3fde00b (diff)
downloadxmobar-63303977071f34d8142709960e8dae97cea1951e.tar.gz
xmobar-63303977071f34d8142709960e8dae97cea1951e.tar.bz2
examples -> etc
Diffstat (limited to 'examples/xmonadpropwrite.hs')
-rw-r--r--examples/xmonadpropwrite.hs41
1 files changed, 0 insertions, 41 deletions
diff --git a/examples/xmonadpropwrite.hs b/examples/xmonadpropwrite.hs
deleted file mode 100644
index f3f4a5d..0000000
--- a/examples/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