[Xmonad] X Events in a Status Bar

Andrea Rossato mailing_list at istitutocolli.org
Tue Jul 17 09:09:35 EDT 2007

On Tue, Jul 17, 2007 at 02:12:15PM +0200, Robert Manea wrote:
>   - Have all the X stuff in a separate thread which can block
>   - Use some signaling to inform the thread there is new data

I did a mix of the two: before blocking the main thread with
XNextEvent I create a background thread. This will wait for the
configured interval and then will send an expose event to the window,
which will unblock XNextEvent.

Since the window's event_mask includes only Expose, I'm not even
capturing the Event.

Sound hackish, too hackish, but I did not find a quicker way.

What do you think?

thanks for your help.


the code just for reference

-- | The event loop
eventLoop :: Xbar ()
eventLoop =
    do c <- ask
       s <- get
       io $ forkIO $ sendUpdateMsg (display s) (window s) (refresh c)
       action <- io $ allocaXEvent $ \e ->
                 do nextEvent (display s) e -- just wait...
                    return updateWin -- ok, it's time

sendUpdateMsg :: Display -> Window -> Int -> IO ()
sendUpdateMsg dpy w d = 
    do tenthSeconds d
       allocaXEvent $ \e -> do
         setEventType e expose
         sendEvent dpy w False noEventMask e 
       sync dpy False

More information about the Xmonad mailing list