<commit_before>-- 
-- DynamicLog
--
-- Log events in:
--
--      1 2 [3] 4 8
--
-- format. suitable to pipe into dzen.
--
-- To use, set:
--
--      import XMonadContrib.DynamicLog
--      logHook = dynamicLog
--
-- <NAME>

module XMonadContrib.DynamicLog where

-- 
-- Useful imports
--
import XMonad
import Data.List
import qualified StackSet as S

--
-- Perform an arbitrary action on each state change.
-- Examples include:
--      * do nothing
--      * log the state to stdout

--
-- An example logger, print a status bar output to dzen, in the form:
--
--  1 2 [3] 4 7
--  

dynamicLog :: X ()
dynamicLog = withWindowSet $ io . putStrLn . ppr
  where
    ppr s =  concatMap fmt $ sortBy tags
                (map S.workspace (S.current s : S.visible s) ++ S.hidden s)

       where tags a b = S.tag a `compare` S.tag b
             this     = S.tag (S.workspace (S.current s))
             pprTag   = show . (+(1::Int)) . fromIntegral . S.tag
             fmt w | S.tag w == this      = "[" ++ pprTag w ++ "]"
                   | S.stack w /= S.Empty = " " ++ pprTag w ++ " "
                   | otherwise            = ""<commit_msg>tag visibles with <N><commit_after>-- 
-- DynamicLog
--
-- Log events in:
--
--      1 2 [3] 4 8
--
-- format. suitable to pipe into dzen.
--
-- To use, set:
--
--      import XMonadContrib.DynamicLog
--      logHook = dynamicLog
--
-- <NAME>

module XMonadContrib.DynamicLog where

-- 
-- Useful imports
--
import XMonad
import Data.List
import qualified StackSet as S

--
-- Perform an arbitrary action on each state change.
-- Examples include:
--      * do nothing
--      * log the state to stdout

--
-- An example logger, print a status bar output to dzen, in the form:
--
--  1 2 [3] 4 7
--  

dynamicLog :: X ()
dynamicLog = withWindowSet $ io . putStrLn . ppr
  where
    ppr s =  concatMap fmt $ sortBy tags
                (map S.workspace (S.current s : S.visible s) ++ S.hidden s)
       where tags a b = S.tag a `compare` S.tag b
             this     = S.tag (S.workspace (S.current s))
             pprTag   = show . (+(1::Int)) . fromIntegral . S.tag
             visibles = map (S.tag . S.workspace) (S.visible s)

             fmt w | S.tag w == this         = "[" ++ pprTag w ++ "]"
                   | S.tag w `elem` visibles = "<" ++ pprTag w ++ ">"
                   | S.stack w /= S.Empty    = " " ++ pprTag w ++ " "
                   | otherwise               = ""
{'fraction_non_alphanumeric': 0.14209445585215605, 'fraction_numerical': 0.009034907597535934, 'mean_word_length': 1.5805084745762712, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3654594', 'n_tokens_mistral': 833, 'n_tokens_neox': 805, 'n_words': 269}