I use dynamicLogWithPPfrom XMonad.Hooks.DynamicLogalong with dzen2 as the status bar in xmonad. One of the things that I would like to display in the bar is the time remaining on the current game track in bold (if any). Getting this information is easy:
audStatus :: Player -> X (Maybe String)
audStatus p = do
info <- liftIO $ tryS $ withPlayer p $ do
ispaused <- paused
md <- getMetadataString
timeleftmillis <- (-) <$> (getCurrentTrack >>= songFrames) <*> time
let artist = md ! "artist"
title = md ! "title"
timeleft = timeleftmillis `quot` 1000
(minutes, seconds) = timeleft `quotRem` 60
disp = artist ++ " - " ++ title ++ " (-"++(show minutes)++":"++(show seconds)++")" -- will be wrong if seconds < 10
audcolor False = dzenColor base0 base03
audcolor True = dzenColor base1 base02
return $ wrap "^ca(1, pms p)" "^ca()" (audcolor ispaused disp)
return $ either (const Nothing) Just info
Therefore, I can stick to this in ppExtras, and it works fine - in addition, it only starts when it starts logHook, and this only happens when a suitable event leaves the pike. Thus, the display is potentially static for a long time, until I (for example) move to workspaces.
, , script. ? xmonad ( /)?
ETA: , , , :
- TChan XMonad, Audacious;
ppOutput PP DynamicLog TChan;- TChan;
- fork TChans ( , , ) .
XMonad , Audacious . , - .