mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
scripts/xmonadpropread: Document and support custom props
This commit is contained in:
parent
cdc6c6d39c
commit
ccebeb675d
@ -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
|
||||
|
@ -1,20 +1,38 @@
|
||||
-- Copyright Spencer Janssen <spencerjanssen@gmail.com>
|
||||
-- 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user