[Xmonad] X Events in a Status Bar

Robert Manea rob.manea at googlemail.com
Tue Jul 17 08:12:15 EDT 2007

* Andrea Rossato (mailing_list at istitutocolli.org) wrote:

> For instance, in dzen you have a "while running handle_xev()", and
> handle_xev is a case analysis ("switch case Exposure" etc etc).
> Now, as far as I know, dzen receives a string and prints it.

Well no, actually it's more like:

while(we're running) 
   sd = watch(stdin);
   xd = watch(X descriptor);

   select(sd, xd);     -- we block here until there is sth. to do

      - read the line and write it to a buffer
     handle(X events)
      - get the buffer's contents and 
      - render them to a pixmap and
      - render them to screen

So if we receive requests on xd we can just generate or copy the pixmaps
to the actual window while still using blocking functions like read()
and XNextEvent().

> Now, my loop is: "while running":
> 1. readVariablesSetByOtherThreads()
> 2. printVariablesInPixmap
> 3. copyPixmapToWindow
> 4. start reading again.

Ok, so there are at least 2 possible solutions:

  - Have all the X stuff in a separate thread which can block
  - Use some signaling to inform the thread there is new data

> Now can I intercept an Expose event without XNextEvent()? Or, is
> there a function like XNextEvent that takes a timeout argument?

No timeout for XNextEvent(), though there are a couple of non-blocking
functions to retrieve the events like XPending().

> Thanks for your kind attention (as usual!).
> Andrea

Bye, Rob.

More information about the Xmonad mailing list