{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}
module XMonad.Hooks.StatusBar.PP (
PP(..), def,
dynamicLogString,
dynamicLogString',
dynamicLogWithPP,
WS(..), WSPP, WSPP', fallbackPrinters,
isUrgent, isCurrent, isVisible, isVisibleNoWindows, isHidden,
dzenPP, xmobarPP, sjanssenPP, byorgeyPP,
wrap, pad, trim, shorten, shorten', shortenLeft, shortenLeft',
xmobarColor, xmobarFont, xmobarAction, xmobarBorder,
xmobarRaw, xmobarStrip, xmobarStripTags,
dzenColor, dzenEscape, dzenStrip, filterOutWsPP,
pprWindowSet,
pprWindowSetXinerama
) where
import Control.Monad.Reader
import Control.DeepSeq
import qualified Data.List.NonEmpty as NE
import XMonad
import XMonad.Prelude
import qualified XMonad.StackSet as S
import XMonad.Util.NamedWindows
import XMonad.Util.WorkspaceCompare
import XMonad.Hooks.UrgencyHook
data PP = PP { PP -> [Char] -> [Char]
ppCurrent :: WorkspaceId -> String
, PP -> [Char] -> [Char]
ppVisible :: WorkspaceId -> String
, PP -> [Char] -> [Char]
ppHidden :: WorkspaceId -> String
, PP -> [Char] -> [Char]
ppHiddenNoWindows :: WorkspaceId -> String
, PP -> Maybe ([Char] -> [Char])
ppVisibleNoWindows :: Maybe (WorkspaceId -> String)
, PP -> [Char] -> [Char]
ppUrgent :: WorkspaceId -> String
, PP -> [Char] -> WindowSpace -> [Char]
ppRename :: String -> WindowSpace -> String
, PP -> [Char]
ppSep :: String
, PP -> [Char]
ppWsSep :: String
, PP -> [Char] -> [Char]
ppTitle :: String -> String
, PP -> [Char] -> [Char]
ppTitleSanitize :: String -> String
, PP -> [Char] -> [Char]
ppLayout :: String -> String
, PP -> [[Char]] -> [[Char]]
ppOrder :: [String] -> [String]
, PP -> X ([WindowSpace] -> [WindowSpace])
ppSort :: X ([WindowSpace] -> [WindowSpace])
, :: [X (Maybe String)]
, PP -> [Char] -> IO ()
ppOutput :: String -> IO ()
, PP -> WSPP
ppPrinters :: WSPP
}
instance Default PP where
def :: PP
def = PP { ppCurrent :: [Char] -> [Char]
ppCurrent = [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
"[" [Char]
"]"
, ppVisible :: [Char] -> [Char]
ppVisible = [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
"<" [Char]
">"
, ppHidden :: [Char] -> [Char]
ppHidden = [Char] -> [Char]
forall a. a -> a
id
, ppHiddenNoWindows :: [Char] -> [Char]
ppHiddenNoWindows = [Char] -> [Char] -> [Char]
forall a b. a -> b -> a
const [Char]
""
, ppVisibleNoWindows :: Maybe ([Char] -> [Char])
ppVisibleNoWindows = Maybe ([Char] -> [Char])
forall a. Maybe a
Nothing
, ppUrgent :: [Char] -> [Char]
ppUrgent = [Char] -> [Char]
forall a. a -> a
id
, ppRename :: [Char] -> WindowSpace -> [Char]
ppRename = [Char] -> WindowSpace -> [Char]
forall a. a -> WindowSpace -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
, ppSep :: [Char]
ppSep = [Char]
" : "
, ppWsSep :: [Char]
ppWsSep = [Char]
" "
, ppTitle :: [Char] -> [Char]
ppTitle = Int -> [Char] -> [Char]
shorten Int
80
, ppTitleSanitize :: [Char] -> [Char]
ppTitleSanitize = [Char] -> [Char]
xmobarStrip ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [Char]
dzenEscape
, ppLayout :: [Char] -> [Char]
ppLayout = [Char] -> [Char]
forall a. a -> a
id
, ppOrder :: [[Char]] -> [[Char]]
ppOrder = [[Char]] -> [[Char]]
forall a. a -> a
id
, ppOutput :: [Char] -> IO ()
ppOutput = [Char] -> IO ()
putStrLn
, ppSort :: X ([WindowSpace] -> [WindowSpace])
ppSort = X ([WindowSpace] -> [WindowSpace])
getSortByIndex
, ppExtras :: [X (Maybe [Char])]
ppExtras = []
, ppPrinters :: WSPP
ppPrinters = WSPP
forall a. ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a
empty
}
dynamicLogWithPP :: PP -> X ()
dynamicLogWithPP :: PP -> X ()
dynamicLogWithPP PP
pp = PP -> X [Char]
dynamicLogString PP
pp X [Char] -> ([Char] -> X ()) -> X ()
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> ([Char] -> IO ()) -> [Char] -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PP -> [Char] -> IO ()
ppOutput PP
pp
dynamicLogString :: PP -> X String
dynamicLogString :: PP -> X [Char]
dynamicLogString PP
pp = [Char] -> X [Char] -> X [Char]
forall a. a -> X a -> X a
userCodeDef [Char]
"_|_" (PP -> X [Char]
dynamicLogString' PP
pp)
dynamicLogString' :: PP -> X String
dynamicLogString' :: PP -> X [Char]
dynamicLogString' PP
pp = do
winset <- (XState
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail)
-> X (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail)
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets XState
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
windowset
urgents <- readUrgents
sort' <- ppSort pp
let ld = Layout Window -> [Char]
forall (layout :: * -> *) a.
LayoutClass layout a =>
layout a -> [Char]
description (Layout Window -> [Char])
-> (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Layout Window)
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSpace -> Layout Window
forall i l a. Workspace i l a -> l
S.layout (WindowSpace -> Layout Window)
-> (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace)
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Layout Window
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
S.workspace (Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace)
-> (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Screen [Char] (Layout Window) Window ScreenId ScreenDetail)
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Screen [Char] (Layout Window) Window ScreenId ScreenDetail
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
S.current (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char])
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
forall a b. (a -> b) -> a -> b
$ StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
winset
let ws = ([WindowSpace] -> [WindowSpace])
-> [Window]
-> PP
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
pprWindowSet [WindowSpace] -> [WindowSpace]
sort' [Window]
urgents PP
pp StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
winset
extras <- mapM (userCodeDef Nothing) $ ppExtras pp
wt <- maybe (pure "") (fmap show . getName) . S.peek $ winset
return $! force $ sepBy (ppSep pp) . ppOrder pp $
[ ws
, ppLayout pp ld
, ppTitle pp $ ppTitleSanitize pp wt
]
++ catMaybes extras
pprWindowSet :: WorkspaceSort -> [Window] -> PP -> WindowSet -> String
pprWindowSet :: ([WindowSpace] -> [WindowSpace])
-> [Window]
-> PP
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
pprWindowSet [WindowSpace] -> [WindowSpace]
sort' [Window]
urgents PP
pp StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
s = [Char] -> [[Char]] -> [Char]
sepBy (PP -> [Char]
ppWsSep PP
pp) ([[Char]] -> [Char])
-> ([WindowSpace] -> [[Char]]) -> [WindowSpace] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WindowSpace -> [Char]) -> [WindowSpace] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map WindowSpace -> [Char]
fmt ([WindowSpace] -> [[Char]])
-> ([WindowSpace] -> [WindowSpace]) -> [WindowSpace] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [WindowSpace] -> [WindowSpace]
sort' ([WindowSpace] -> [Char]) -> [WindowSpace] -> [Char]
forall a b. (a -> b) -> a -> b
$
(Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace)
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [WindowSpace]
forall a b. (a -> b) -> [a] -> [b]
map Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
S.workspace (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Screen [Char] (Layout Window) Window ScreenId ScreenDetail
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
S.current StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
s Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
forall a. a -> [a] -> [a]
: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
S.visible StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
s) [WindowSpace] -> [WindowSpace] -> [WindowSpace]
forall a. [a] -> [a] -> [a]
++ StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [WindowSpace]
forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
S.hidden StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
s
where
fmt :: WindowSpace -> String
fmt :: WindowSpace -> [Char]
fmt WindowSpace
w = [Char] -> [Char]
pr (PP -> [Char] -> WindowSpace -> [Char]
ppRename PP
pp (WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag WindowSpace
w) WindowSpace
w)
where
printers :: WSPP
printers = PP -> WSPP
ppPrinters PP
pp WSPP -> WSPP -> WSPP
forall a.
ReaderT WS Maybe a -> ReaderT WS Maybe a -> ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> WSPP
fallbackPrinters
pr :: [Char] -> [Char]
pr = ([Char] -> [Char]) -> Maybe ([Char] -> [Char]) -> [Char] -> [Char]
forall a. a -> Maybe a -> a
fromMaybe [Char] -> [Char]
forall a. a -> a
id (Maybe ([Char] -> [Char]) -> [Char] -> [Char])
-> Maybe ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ WSPP -> WS -> Maybe ([Char] -> [Char])
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT WSPP
printers (WS -> Maybe ([Char] -> [Char])) -> WS -> Maybe ([Char] -> [Char])
forall a b. (a -> b) -> a -> b
$
WS{ wsUrgents :: [Window]
wsUrgents = [Window]
urgents, wsWindowSet :: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWindowSet = StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
s, wsWS :: WindowSpace
wsWS = WindowSpace
w, wsPP :: PP
wsPP = PP
pp }
data WS = WS{ WS -> [Window]
wsUrgents :: [Window]
, WS -> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWindowSet :: WindowSet
, WS -> WindowSpace
wsWS :: WindowSpace
, WS -> PP
wsPP :: PP
}
type WSPP' = ReaderT WS Maybe
type WSPP = WSPP' (WorkspaceId -> String)
fallbackPrinters :: WSPP
fallbackPrinters :: WSPP
fallbackPrinters = WS -> Bool
isUrgent (WS -> Bool) -> (PP -> [Char] -> [Char]) -> WSPP
forall {f :: * -> *} {b}.
(Alternative f, MonadReader WS f) =>
(WS -> Bool) -> (PP -> b) -> f b
?-> PP -> [Char] -> [Char]
ppUrgent
WSPP -> WSPP -> WSPP
forall a.
ReaderT WS Maybe a -> ReaderT WS Maybe a -> ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> WS -> Bool
isCurrent' (WS -> Bool) -> (PP -> [Char] -> [Char]) -> WSPP
forall {f :: * -> *} {b}.
(Alternative f, MonadReader WS f) =>
(WS -> Bool) -> (PP -> b) -> f b
?-> PP -> [Char] -> [Char]
ppCurrent
WSPP -> WSPP -> WSPP
forall a.
ReaderT WS Maybe a -> ReaderT WS Maybe a -> ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> WS -> Bool
isVisible' (WS -> Bool) -> (PP -> [Char] -> [Char]) -> WSPP
forall {f :: * -> *} {b}.
(Alternative f, MonadReader WS f) =>
(WS -> Bool) -> (PP -> b) -> f b
?-> PP -> [Char] -> [Char]
ppVisible
WSPP -> WSPP -> WSPP
forall a.
ReaderT WS Maybe a -> ReaderT WS Maybe a -> ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> WS -> Bool
isVisibleNoWindows' (WS -> Bool) -> (PP -> [Char] -> [Char]) -> WSPP
forall {f :: * -> *} {b}.
(Alternative f, MonadReader WS f) =>
(WS -> Bool) -> (PP -> b) -> f b
?-> (([Char] -> [Char])
-> Maybe ([Char] -> [Char]) -> [Char] -> [Char])
-> (PP -> [Char] -> [Char])
-> (PP -> Maybe ([Char] -> [Char]))
-> PP
-> [Char]
-> [Char]
forall a b c. (a -> b -> c) -> (PP -> a) -> (PP -> b) -> PP -> c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 ([Char] -> [Char]) -> Maybe ([Char] -> [Char]) -> [Char] -> [Char]
forall a. a -> Maybe a -> a
fromMaybe PP -> [Char] -> [Char]
ppVisible PP -> Maybe ([Char] -> [Char])
ppVisibleNoWindows
WSPP -> WSPP -> WSPP
forall a.
ReaderT WS Maybe a -> ReaderT WS Maybe a -> ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> WS -> Bool
isHidden' (WS -> Bool) -> (PP -> [Char] -> [Char]) -> WSPP
forall {f :: * -> *} {b}.
(Alternative f, MonadReader WS f) =>
(WS -> Bool) -> (PP -> b) -> f b
?-> PP -> [Char] -> [Char]
ppHidden
WSPP -> WSPP -> WSPP
forall a.
ReaderT WS Maybe a -> ReaderT WS Maybe a -> ReaderT WS Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> WS -> Bool
forall a. a -> WS -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
True (WS -> Bool) -> (PP -> [Char] -> [Char]) -> WSPP
forall {f :: * -> *} {b}.
(Alternative f, MonadReader WS f) =>
(WS -> Bool) -> (PP -> b) -> f b
?-> PP -> [Char] -> [Char]
ppHiddenNoWindows
where
WS -> Bool
cond ?-> :: (WS -> Bool) -> (PP -> b) -> f b
?-> PP -> b
ppr = ((WS -> Bool) -> f Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks WS -> Bool
cond f Bool -> (Bool -> f ()) -> f ()
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> f ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard) f () -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (WS -> b) -> f b
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (PP -> b
ppr (PP -> b) -> (WS -> PP) -> WS -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WS -> PP
wsPP)
isUrgent :: WS -> Bool
isUrgent :: WS -> Bool
isUrgent WS{[Window]
StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
WindowSpace
PP
wsUrgents :: WS -> [Window]
wsWindowSet :: WS -> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWS :: WS -> WindowSpace
wsPP :: WS -> PP
wsUrgents :: [Window]
wsWindowSet :: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWS :: WindowSpace
wsPP :: PP
..} = (Window -> Bool) -> [Window] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (\Window
x -> (Maybe [Char] -> Maybe [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char] -> Maybe [Char]
forall a. a -> Maybe a
Just (WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag WindowSpace
wsWS)) (Window
-> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Maybe [Char]
forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
S.findTag Window
x StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWindowSet)) [Window]
wsUrgents
isCurrent' :: WS -> Bool
isCurrent' :: WS -> Bool
isCurrent' WS{[Window]
StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
WindowSpace
PP
wsUrgents :: WS -> [Window]
wsWindowSet :: WS -> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWS :: WS -> WindowSpace
wsPP :: WS -> PP
wsUrgents :: [Window]
wsWindowSet :: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWS :: WindowSpace
wsPP :: PP
..} = WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag WindowSpace
wsWS [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
forall i l a s sd. StackSet i l a s sd -> i
S.currentTag StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWindowSet
isCurrent :: WS -> Bool
isCurrent :: WS -> Bool
isCurrent = (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isUrgent) (WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> WS -> Bool
isCurrent'
isVisible' :: WS -> Bool
isVisible' :: WS -> Bool
isVisible' = WS -> Bool
isVisibleNoWindows' (WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> Maybe (Stack Window) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (Stack Window) -> Bool)
-> (WS -> Maybe (Stack Window)) -> WS -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSpace -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
S.stack (WindowSpace -> Maybe (Stack Window))
-> (WS -> WindowSpace) -> WS -> Maybe (Stack Window)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WS -> WindowSpace
wsWS
isVisible :: WS -> Bool
isVisible :: WS -> Bool
isVisible = (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isUrgent) (WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isCurrent') (WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> WS -> Bool
isVisible'
isVisibleNoWindows' :: WS -> Bool
isVisibleNoWindows' :: WS -> Bool
isVisibleNoWindows' WS{[Window]
StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
WindowSpace
PP
wsUrgents :: WS -> [Window]
wsWindowSet :: WS -> StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWS :: WS -> WindowSpace
wsPP :: WS -> PP
wsUrgents :: [Window]
wsWindowSet :: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWS :: WindowSpace
wsPP :: PP
..} = WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag WindowSpace
wsWS [Char] -> [[Char]] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Char]]
visibles
where visibles :: [[Char]]
visibles = (Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char])
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag (WindowSpace -> [Char])
-> (Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace)
-> Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
S.workspace) (StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
S.visible StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
wsWindowSet)
isVisibleNoWindows :: WS -> Bool
isVisibleNoWindows :: WS -> Bool
isVisibleNoWindows =
(Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isUrgent)
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isCurrent')
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isVisible')
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> WS -> Bool
isVisibleNoWindows'
isHidden' :: WS -> Bool
isHidden' :: WS -> Bool
isHidden' = Maybe (Stack Window) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (Stack Window) -> Bool)
-> (WS -> Maybe (Stack Window)) -> WS -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSpace -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
S.stack (WindowSpace -> Maybe (Stack Window))
-> (WS -> WindowSpace) -> WS -> Maybe (Stack Window)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WS -> WindowSpace
wsWS
isHidden :: WS -> Bool
isHidden :: WS -> Bool
isHidden =
(Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isUrgent)
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isCurrent')
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isVisible')
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> (Bool -> Bool
not (Bool -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WS -> Bool
isVisibleNoWindows')
(WS -> Bool) -> (WS -> Bool) -> WS -> Bool
forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
<&&> WS -> Bool
isHidden'
pprWindowSetXinerama :: WindowSet -> String
pprWindowSetXinerama :: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
pprWindowSetXinerama StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
ws = [Char]
"[" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
unwords [[Char]]
onscreen [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"] " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
unwords [[Char]]
offscreen
where onscreen :: [[Char]]
onscreen = (Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char])
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag (WindowSpace -> [Char])
-> (Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace)
-> Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> WindowSpace
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
S.workspace)
([Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [[Char]])
-> ([Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail])
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> ScreenId)
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> ScreenId
forall i l a sid sd. Screen i l a sid sd -> sid
S.screen ([Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [[Char]])
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [[Char]]
forall a b. (a -> b) -> a -> b
$ StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> Screen [Char] (Layout Window) Window ScreenId ScreenDetail
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
S.current StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
ws Screen [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
forall a. a -> [a] -> [a]
: StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [Screen [Char] (Layout Window) Window ScreenId ScreenDetail]
forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
S.visible StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
ws
offscreen :: [[Char]]
offscreen = (WindowSpace -> [Char]) -> [WindowSpace] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag ([WindowSpace] -> [[Char]])
-> ([WindowSpace] -> [WindowSpace]) -> [WindowSpace] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WindowSpace -> Bool) -> [WindowSpace] -> [WindowSpace]
forall a. (a -> Bool) -> [a] -> [a]
filter (Maybe (Stack Window) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (Stack Window) -> Bool)
-> (WindowSpace -> Maybe (Stack Window)) -> WindowSpace -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSpace -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
S.stack)
([WindowSpace] -> [WindowSpace])
-> ([WindowSpace] -> [WindowSpace])
-> [WindowSpace]
-> [WindowSpace]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WindowSpace -> [Char]) -> [WindowSpace] -> [WindowSpace]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn WindowSpace -> [Char]
forall i l a. Workspace i l a -> i
S.tag ([WindowSpace] -> [[Char]]) -> [WindowSpace] -> [[Char]]
forall a b. (a -> b) -> a -> b
$ StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
-> [WindowSpace]
forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
S.hidden StackSet [Char] (Layout Window) Window ScreenId ScreenDetail
ws
wrap :: String
-> String
-> String
-> String
wrap :: [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
_ [Char]
_ [Char]
"" = [Char]
""
wrap [Char]
l [Char]
r [Char]
m = [Char]
l [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
m [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
r
pad :: String -> String
pad :: [Char] -> [Char]
pad = [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
" " [Char]
" "
trim :: String -> String
trim :: [Char] -> [Char]
trim = [Char] -> [Char]
f ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [Char]
f
where f :: [Char] -> [Char]
f = [Char] -> [Char]
forall a. [a] -> [a]
reverse ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> [Char] -> [Char]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile Char -> Bool
isSpace
shorten :: Int -> String -> String
shorten :: Int -> [Char] -> [Char]
shorten = [Char] -> Int -> [Char] -> [Char]
shorten' [Char]
"..."
shorten' :: String -> Int -> String -> String
shorten' :: [Char] -> Int -> [Char] -> [Char]
shorten' [Char]
end Int
n [Char]
xs | [Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
xs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
n = [Char]
xs
| Bool
otherwise = Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
take (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- [Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
end) [Char]
xs [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
end
shortenLeft :: Int -> String -> String
shortenLeft :: Int -> [Char] -> [Char]
shortenLeft = [Char] -> Int -> [Char] -> [Char]
shortenLeft' [Char]
"..."
shortenLeft' :: String -> Int -> String -> String
shortenLeft' :: [Char] -> Int -> [Char] -> [Char]
shortenLeft' [Char]
end Int
n [Char]
xs | Int
l Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
n = [Char]
xs
| Bool
otherwise = [Char]
end [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
drop (Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
end) [Char]
xs
where l :: Int
l = [Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
xs
sepBy :: String
-> [String]
-> String
sepBy :: [Char] -> [[Char]] -> [Char]
sepBy [Char]
sep = [Char] -> [[Char]] -> [Char]
forall a. [a] -> [[a]] -> [a]
intercalate [Char]
sep ([[Char]] -> [Char])
-> ([[Char]] -> [[Char]]) -> [[Char]] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> Bool) -> [[Char]] -> [[Char]]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ([Char] -> Bool) -> [Char] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null)
dzenColor :: String
-> String
-> String
-> String
dzenColor :: [Char] -> [Char] -> [Char] -> [Char]
dzenColor [Char]
fg [Char]
bg = [Char] -> [Char] -> [Char] -> [Char]
wrap ([Char]
fg1[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
bg1) ([Char]
fg2[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
bg2)
where ([Char]
fg1,[Char]
fg2) | [Char] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Char]
fg = ([Char]
"",[Char]
"")
| Bool
otherwise = ([Char]
"^fg(" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
fg [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
")",[Char]
"^fg()")
([Char]
bg1,[Char]
bg2) | [Char] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Char]
bg = ([Char]
"",[Char]
"")
| Bool
otherwise = ([Char]
"^bg(" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
bg [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
")",[Char]
"^bg()")
dzenEscape :: String -> String
dzenEscape :: [Char] -> [Char]
dzenEscape = (Char -> [Char]) -> [Char] -> [Char]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\Char
x -> if Char
x Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'^' then [Char]
"^^" else [Char
x])
dzenStrip :: String -> String
dzenStrip :: [Char] -> [Char]
dzenStrip = [Char] -> [Char] -> [Char]
strip [] where
strip :: [Char] -> [Char] -> [Char]
strip [Char]
keep [Char]
x
| [Char] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Char]
x = [Char]
keep
| [Char]
"^^" [Char] -> [Char] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` [Char]
x = [Char] -> [Char] -> [Char]
strip ([Char]
keep [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"^") (Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
drop Int
2 [Char]
x)
| [Char]
"^" [Char] -> [Char] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` [Char]
x = [Char] -> [Char] -> [Char]
strip [Char]
keep (Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
drop Int
1 ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> [Char] -> [Char]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
')') ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ [Char]
x)
| Bool
otherwise = let ([Char]
good,[Char]
x') = (Char -> Bool) -> [Char] -> ([Char], [Char])
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'^') [Char]
x
in [Char] -> [Char] -> [Char]
strip ([Char]
keep [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
good) [Char]
x'
xmobarFont :: Int
-> String
-> String
xmobarFont :: Int -> [Char] -> [Char]
xmobarFont Int
index = [Char] -> [Char] -> [Char] -> [Char]
wrap ([Char]
"<fn=" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show Int
index [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
">") [Char]
"</fn>"
xmobarColor :: String
-> String
-> String
-> String
xmobarColor :: [Char] -> [Char] -> [Char] -> [Char]
xmobarColor [Char]
fg [Char]
bg = [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
t [Char]
"</fc>"
where t :: [Char]
t = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Char]
"<fc=", [Char]
fg, if [Char] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Char]
bg then [Char]
"" else [Char]
"," [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
bg, [Char]
">"]
xmobarAction :: String
-> String
-> String
-> String
xmobarAction :: [Char] -> [Char] -> [Char] -> [Char]
xmobarAction [Char]
command [Char]
button = [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
l [Char]
r
where
l :: [Char]
l = [Char]
"<action=`" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
command [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"` button=" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
button [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
">"
r :: [Char]
r = [Char]
"</action>"
xmobarBorder :: String
-> String
-> Int
-> String
-> String
xmobarBorder :: [Char] -> [Char] -> Int -> [Char] -> [Char]
xmobarBorder [Char]
border [Char]
color Int
width = [Char] -> [Char] -> [Char] -> [Char]
wrap [Char]
prefix [Char]
"</box>"
where
prefix :: [Char]
prefix = [Char]
"<box type=" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
border [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" width=" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show Int
width [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" color="
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
color [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
">"
xmobarRaw :: String -> String
xmobarRaw :: [Char] -> [Char]
xmobarRaw [Char]
"" = [Char]
""
xmobarRaw [Char]
s = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Char]
"<raw=", Int -> [Char]
forall a. Show a => a -> [Char]
show (Int -> [Char]) -> Int -> [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
s, [Char]
":", [Char]
s, [Char]
"/>"]
xmobarStrip :: String -> String
xmobarStrip :: [Char] -> [Char]
xmobarStrip = ([Char] -> [Char]) -> [Char] -> [Char]
forall a. Eq a => (a -> a) -> a -> a
converge ([[Char]] -> [Char] -> [Char]
xmobarStripTags [[Char]
"fc",[Char]
"icon",[Char]
"action"])
converge :: (Eq a) => (a -> a) -> a -> a
converge :: forall a. Eq a => (a -> a) -> a -> a
converge a -> a
f a
a
= (a, a) -> a
forall a b. (a, b) -> a
fst ((a, a) -> a) -> ([a] -> (a, a)) -> [a] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty (a, a) -> (a, a)
forall a. NonEmpty a -> a
NE.head (NonEmpty (a, a) -> (a, a))
-> ([a] -> NonEmpty (a, a)) -> [a] -> (a, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(a, a)] -> NonEmpty (a, a)
forall a. HasCallStack => [a] -> NonEmpty a
notEmpty
([(a, a)] -> NonEmpty (a, a))
-> ([a] -> [(a, a)]) -> [a] -> NonEmpty (a, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, a) -> Bool) -> [(a, a)] -> [(a, a)]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile ((a -> a -> Bool) -> (a, a) -> Bool
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry a -> a -> Bool
forall a. Eq a => a -> a -> Bool
(/=))
([(a, a)] -> [(a, a)]) -> ([a] -> [(a, a)]) -> [a] -> [(a, a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a] -> [(a, a)]
forall a b. [a] -> [b] -> [(a, b)]
zip [a]
xs
([a] -> a) -> [a] -> a
forall a b. (a -> b) -> a -> b
$ Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
1 [a]
xs
where xs :: [a]
xs = (a -> a) -> a -> [a]
forall a. (a -> a) -> a -> [a]
iterate a -> a
f a
a
xmobarStripTags :: [String]
-> String -> String
xmobarStripTags :: [[Char]] -> [Char] -> [Char]
xmobarStripTags [[Char]]
tags = [Char] -> [Char] -> [Char]
strip [] where
strip :: [Char] -> [Char] -> [Char]
strip [Char]
keep [] = [Char]
keep
strip [Char]
keep [Char]
x
| [Char]
rest: [[Char]]
_ <- ([Char] -> Maybe [Char]) -> [[Char]] -> [[Char]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe [Char] -> Maybe [Char]
dropTag [[Char]]
tags = [Char] -> [Char] -> [Char]
strip [Char]
keep [Char]
rest
| Char
'<':[Char]
xs <- [Char]
x = [Char] -> [Char] -> [Char]
strip ([Char]
keep [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"<") [Char]
xs
| ([Char]
good,[Char]
x') <- (Char -> Bool) -> [Char] -> ([Char], [Char])
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'<') [Char]
x = [Char] -> [Char] -> [Char]
strip ([Char]
keep [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
good) [Char]
x'
where dropTag :: String -> Maybe String
dropTag :: [Char] -> Maybe [Char]
dropTag [Char]
tag = [Maybe [Char]] -> Maybe [Char]
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum [([Char] -> [Char]) -> Maybe [Char] -> Maybe [Char]
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Char] -> [Char]
dropTilClose ([Char] -> [Char]
openTag [Char]
tag [Char] -> [Char] -> Maybe [Char]
forall a. Eq a => [a] -> [a] -> Maybe [a]
`stripPrefix` [Char]
x),
[Char] -> [Char]
closeTag [Char]
tag [Char] -> [Char] -> Maybe [Char]
forall a. Eq a => [a] -> [a] -> Maybe [a]
`stripPrefix` [Char]
x]
dropTilClose, openTag, closeTag :: String -> String
dropTilClose :: [Char] -> [Char]
dropTilClose = Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
drop Int
1 ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> [Char] -> [Char]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'>')
openTag :: [Char] -> [Char]
openTag [Char]
str = [Char]
"<" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
str [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"="
closeTag :: [Char] -> [Char]
closeTag [Char]
str = [Char]
"</" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
str [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
">"
filterOutWsPP :: [WorkspaceId] -> PP -> PP
filterOutWsPP :: [[Char]] -> PP -> PP
filterOutWsPP [[Char]]
ws PP
pp = PP
pp { ppSort = (. filterOutWs ws) <$> ppSort pp }
dzenPP :: PP
dzenPP :: PP
dzenPP = PP
forall a. Default a => a
def
{ ppCurrent = dzenColor "white" "#2b4f98" . pad
, ppVisible = dzenColor "black" "#999999" . pad
, ppHidden = dzenColor "black" "#cccccc" . pad
, ppHiddenNoWindows = const ""
, ppUrgent = dzenColor "red" "yellow" . pad
, ppWsSep = ""
, ppSep = ""
, ppLayout = dzenColor "black" "#cccccc"
. (\[Char]
x -> [Char] -> [Char]
pad ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ case [Char]
x of
[Char]
"TilePrime Horizontal" -> [Char]
"TTT"
[Char]
"TilePrime Vertical" -> [Char]
"[]="
[Char]
"Hinted Full" -> [Char]
"[ ]"
[Char]
_ -> [Char]
x
)
, ppTitle = ("^bg(#324c80) " ++) . dzenEscape
}
xmobarPP :: PP
xmobarPP :: PP
xmobarPP = PP
forall a. Default a => a
def { ppCurrent = xmobarColor "yellow" "" . wrap "[" "]"
, ppTitle = xmobarColor "green" "" . shorten 40
, ppVisible = wrap "(" ")"
, ppUrgent = xmobarColor "red" "yellow"
}
sjanssenPP :: PP
sjanssenPP :: PP
sjanssenPP = PP
forall a. Default a => a
def { ppCurrent = xmobarColor "white" "black"
, ppTitle = xmobarColor "#00ee00" "" . shorten 120
}
byorgeyPP :: PP
byorgeyPP :: PP
byorgeyPP = PP
forall a. Default a => a
def { ppHiddenNoWindows = showNamedWorkspaces
, ppHidden = dzenColor "black" "#a8a3f7" . pad
, ppCurrent = dzenColor "yellow" "#a8a3f7" . pad
, ppUrgent = dzenColor "red" "yellow" . pad
, ppSep = " | "
, ppWsSep = ""
, ppTitle = shorten 70
, ppOrder = reverse
}
where
showNamedWorkspaces :: [Char] -> [Char]
showNamedWorkspaces [Char]
wsId =
if (Char -> Bool) -> [Char] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Char -> [Char] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char]
wsId) [Char
'a' .. Char
'z'] then [Char] -> [Char]
pad [Char]
wsId else [Char]
""