diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs index c59f9283..789c66c7 100644 --- a/XMonad/Hooks/DynamicLog.hs +++ b/XMonad/Hooks/DynamicLog.hs @@ -154,15 +154,16 @@ import XMonad.Hooks.ManageDocks -- > } -- -- If you don't have an @.xmobarrc@, create it; the @XMonadLog@ plugin is not --- part of the default xmobar configuration and you status bar will not show +-- part of the default xmobar configuration and your status bar will not show -- otherwise! -- -- Because 'statusBarProp' lets you define your own executable, you can also -- give it a different status bar entirely; you only need to make sure that the -- status bar supports reading a property string from the root window, or use --- some kind of wrapper that reads the property and pipes it into the bar. +-- a wrapper that reads the property and pipes it into the bar (e.g. +-- @xmonadpropread | dzen2@, see @scripts/xmonadpropread.hs@). -- --- If you don't want to read from the default property, you can specify your own +-- If you don't want to use the default property, you can specify your own -- with the 'statusBarPropTo' function. -- -- If your status bar does not support property-based logging, you may also try diff --git a/scripts/xmonadpropread.hs b/scripts/xmonadpropread.hs index df7ecbb3..680751b4 100644 --- a/scripts/xmonadpropread.hs +++ b/scripts/xmonadpropread.hs @@ -1,20 +1,38 @@ -- Copyright Spencer Janssen -- BSD3 (see LICENSE) --- --- Experimental, will add proper documentation later (famous last words) +-- +-- Reads from an X property on the root window and writes to standard output. +-- +-- May be used together with XMonad.Hooks.DynamicLog.xmonadPropLog and a +-- status bar that doesn't support reading from properties itself, such as +-- dzen. +-- +-- Usage: +-- +-- $ xmonadpropread | dzen2 +-- +-- or +-- +-- $ xmonadpropread _XMONAD_LOG_CUSTOM | dzen2 import Control.Monad import Graphics.X11 import Graphics.X11.Xlib.Extras import Codec.Binary.UTF8.String as UTF8 import Foreign.C (CChar) +import System.Environment import System.IO +main :: IO () main = do hSetBuffering stdout LineBuffering + atom <- flip fmap getArgs $ \args -> case args of + [a] -> a + _ -> "_XMONAD_LOG" + d <- openDisplay "" - xlog <- internAtom d "_XMONAD_LOG" False + xlog <- internAtom d atom False root <- rootWindow d (defaultScreen d) selectInput d root propertyChangeMask @@ -28,7 +46,5 @@ main = do maybe (return ()) (putStrLn . decodeCChar) mwp _ -> return () - return () - decodeCChar :: [CChar] -> String decodeCChar = UTF8.decode . map fromIntegral