title: can xmonad's logHook be run at set intervals rather than in (merely) response to layout events?
body: <p>I'm using <code>dynamicLogWithPP</code> from <code>XMonad.Hooks.DynamicLog</code> together with dzen2 as a status bar under xmonad. One of the things I'd like to have displayed in the bar is the time remaining in the currently playing track in audacious (if any). Getting this information is easy: </p>
  
  <pre><code>audStatus :: Player -&gt; X (Maybe String)
  audStatus p = do
    info &lt;- liftIO $ tryS $ withPlayer p $ do
                  ispaused &lt;- paused
                  md &lt;- getMetadataString
                  timeleftmillis &lt;- (-) &lt;$&gt; (getCurrentTrack &gt;&gt;= songFrames) &lt;*&gt; 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 &lt; 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
  </code></pre>
  
  <p>So I can stick that in <code>ppExtras</code> and it works fine&mdash;<em>except</em> it only gets run when the <code>logHook</code> gets run, and that happens only when a suitable event comes down the pike. So the display is potentially static for a long time, until I (e.g.) switch workspaces.</p>
  
  <p>It seems like some people just run two dzen bars, with one getting output piped in from a shell script. Is that the only way to have regular updates? Or can this be done from within xmonad (without getting too crazy/hacky)?</p>
  
  <p>ETA: I tried this, which <em>seems</em> as if it should work better than it does:</p>
  
  <ol>
  <li>create a TChan for updates from XMonad, and another for updates from a function polling Audacious;</li>
  <li>set the <code>ppOutput</code> field in the <code>PP</code> structure from <code>DynamicLog</code> to write to the first TChan;</li>
  <li>fork the audacious-polling function and have it write to the second TChan;</li>
  <li>fork a function to read from both TChans (checking that they aren't empty, first), and combining the output.</li>
  </ol>
  
  <p>Updates from XMonad are read from the channel and processed in a timely fashion, but updates from Audacious are hardly registered at all&mdash;every five or so seconds at best. It seems as if some approach along these lines ought to work, though.</p>