aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/XMobarLog.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/XMobarLog.hs')
-rw-r--r--src/Rahm/Desktop/XMobarLog.hs43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/Rahm/Desktop/XMobarLog.hs b/src/Rahm/Desktop/XMobarLog.hs
index d0dcc4f..6ec4ac7 100644
--- a/src/Rahm/Desktop/XMobarLog.hs
+++ b/src/Rahm/Desktop/XMobarLog.hs
@@ -13,6 +13,7 @@ import XMonad.Util.Run (spawnPipe)
import XMonad (X)
import Rahm.Desktop.Workspaces (getPopulatedWorkspaces, WorkspaceState(..))
import Text.Printf
+import Rahm.Desktop.Logger
import qualified XMonad as X
import qualified XMonad.StackSet as S
@@ -38,28 +39,33 @@ xMobarLogHook :: XMobarLog -> X ()
xMobarLogHook (XMobarLog xmproc) = do
(_, _, layoutXpm) <- drawLayout
+ loglevel <- getLogLevel
+
winset <- X.gets X.windowset
title <- maybe (pure "") (fmap show . getName) . S.peek $ winset
let wss = getPopulatedWorkspaces winset
- X.liftIO $ do
- hPutStrLn xmproc $ trunc 80 $ execWriter $ do
- tell " "
- tell layoutXpm
- tell $ " "
+ let log = trunc 80 $ execWriter $ do
+ tell " "
+ tell layoutXpm
+ tell $ " "
+ tell $ logLevelToXMobar loglevel
+
+ forM_ wss $ \(t, ws) -> do
+ case t of
+ Current -> tell "<fn=1><fc=#ff8888>"
+ Visible -> tell "<fn=6><fc=#8888ff>"
+ Hidden -> tell "<fn=2><fc=#888888>"
- forM_ wss $ \(t, ws) -> do
- case t of
- Current -> tell "<fn=1><fc=#ff8888>"
- Visible -> tell "<fn=6><fc=#8888ff>"
- Hidden -> tell "<fn=2><fc=#888888>"
+ tell $ toAction $ S.tag ws
+ tell " </fc></fn>"
- tell $ toAction $ S.tag ws
- tell " </fc></fn>"
+ tell $ " <fc=#ff8888><fn=3>"
+ tell $ title
+ tell $ "</fn></fc>"
- tell $ " <fc=#ff8888><fn=3>"
- tell $ title
- tell $ "</fn></fc>"
+ logs Trace "XMobar: %s" log
+ X.io $ hPutStrLn xmproc log
where
toAction [ch] | (ch >= 'A' && ch <= 'Z') ||
@@ -68,6 +74,13 @@ xMobarLogHook (XMobarLog xmproc) = do
printf "<action=`xdotool key 'Hyper_L+g' '%s'` button=1><action=`xdotool key 'Hyper_L+Shift_L+g' '%s'` button=3>%s</action></action>" [ch] [ch] [ch]
toAction ch = ch
+ logLevelToXMobar Trace = "<fn=3><fc=#88ffff>[Trace]</fc></fn> "
+ logLevelToXMobar Debug = "<fn=3><fc=#ff88ff>[Debug]</fc></fn> "
+ logLevelToXMobar Warn = "<fn=3><fc=#ffff88>[Warn] </fc></fn> "
+ logLevelToXMobar Error = "<fn=3><fc=#ff8888>[Error]</fc></fn> "
+ logLevelToXMobar Fatal = "<fn=3><fc=#888888>[Fatal]</fc></fn> "
+ logLevelToXMobar _ = ""
+
-- Truncate an XMobar string to the provided number of _visible_ characters.
-- This is to keep long window titles from overrunning the whole bar.
trunc :: Int -> String -> String