Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:31:26+00:00 2026-06-17T04:31:26+00:00

I’m using dynamicLogWithPP from XMonad.Hooks.DynamicLog together with dzen2 as a status bar under xmonad.

  • 0

I’m using dynamicLogWithPP from XMonad.Hooks.DynamicLog 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:

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

So I can stick that in ppExtras and it works fine—except it only gets run when the logHook 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.

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)?

ETA: I tried this, which seems as if it should work better than it does:

  1. create a TChan for updates from XMonad, and another for updates from a function polling Audacious;
  2. set the ppOutput field in the PP structure from DynamicLog to write to the first TChan;
  3. fork the audacious-polling function and have it write to the second TChan;
  4. fork a function to read from both TChans (checking that they aren’t empty, first), and combining the output.

Updates from XMonad are read from the channel and processed in a timely fashion, but updates from Audacious are hardly registered at all—every five or so seconds at best. It seems as if some approach along these lines ought to work, though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:31:28+00:00Added an answer on June 17, 2026 at 4:31 am

    I know this is an old question, but I came here looking for an answer to this a few days ago, and I thought I’d share the way I solved it. You actually can do it entirely from xmonad. It’s a tiny bit hacky, but I think it’s much nicer than any of the alternatives I’ve come across.

    Basically, I used the XMonad.Util.Timer library, which will send an X event after a specified time period (in this case, one second). Then I just wrote an event hook for it, which starts the timer again, and then manually runs the log hook.

    I also had to use the XMonad.Util.ExtensibleState library, because Timer uses an id variable to make sure it’s responding to the right event, so I have to store that variable between events.

    Here’s my code:

    {-# LANGUAGE DeriveDataTypeable #-}
    
    import qualified XMonad.Util.ExtensibleState as XS
    import XMonad.Util.Timer
    
    ...
    
    -- wrapper for the Timer id, so it can be stored as custom mutable state
    data TidState = TID TimerId deriving Typeable
    
    instance ExtensionClass TidState where
      initialValue = TID 0
    
    ...
    
    -- put this in your startupHook
    -- start the initial timer, store its id
    clockStartupHook = startTimer 1 >>= XS.put . TID
    
    -- put this in your handleEventHook
    clockEventHook e = do               -- e is the event we've hooked
      (TID t) <- XS.get                 -- get the recent Timer id
      handleTimer t e $ do              -- run the following if e matches the id
        startTimer 1 >>= XS.put . TID   -- restart the timer, store the new id
        ask >>= logHook.config          -- get the loghook and run it
        return Nothing                  -- return required type
      return $ All True                 -- return required type
    

    Pretty straightforward. I hope this is helpful to someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm making a simple page using Google Maps API 3. My first. One marker
I am using jsonparser to parse data and images obtained from json response. When
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.