[xmobar] Ship xmonadpropwrite.hs since it's not shipped
Ben Boeckel
mathstuf at fedoraproject.org
Tue Jan 25 15:41:49 UTC 2011
commit 9ccc9073f105566a496b0bc958e4c8f6c58a355f
Author: Ben Boeckel <ben.boeckel at kitware.com>
Date: Tue Jan 25 10:32:43 2011 -0500
Ship xmonadpropwrite.hs since it's not shipped
xmobar.spec | 5 +++++
xmonadpropwrite.hs | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/xmobar.spec b/xmobar.spec
index 1e0fecf..aa26aea 100644
--- a/xmobar.spec
+++ b/xmobar.spec
@@ -17,6 +17,9 @@ License: BSD
URL: http://hackage.haskell.org/package/%{name}
Source0: http://hackage.haskell.org/packages/archive/%{name}/%{version}/%{name}-%{version}.tar.gz
Source1: xmobar.desktop
+# Not in the package from Hackage.
+# https://github.com/jaor/xmobar/issues/#issue/6
+Source2: xmonadpropwrite.hs
# fedora ghc archs:
ExclusiveArch: %{ix86} x86_64 ppc alpha
BuildRequires: desktop-file-utils
@@ -44,6 +47,8 @@ color management, output templates, and extensibility through plugins.
%prep
%setup -q
+mkdir scripts
+cp %{SOURCE2} scripts/xmonadpropwrite.hs
%build
diff --git a/xmonadpropwrite.hs b/xmonadpropwrite.hs
new file mode 100644
index 0000000..f3f4a5d
--- /dev/null
+++ b/xmonadpropwrite.hs
@@ -0,0 +1,41 @@
+-- Copyright Spencer Janssen <spencerjanssen at gmail.com>
+-- Tomas Janousek <tomi at 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
More information about the scm-commits
mailing list