[xmonad] responding to xrandr events (or: I'm looking for an xmobar-like app that will work with lots of screen rotations)

Wirt Wolff wirtwolff at gmail.com
Fri Nov 4 03:44:21 CET 2011


Excerpts from Rogan Creswick's message of Wed Oct 26 18:12:51 -0600 2011:
> ...
>
> I frequently change the arrangement, orientation, and number of
> monitors on my system (it's a laptop that I dock 5-6x/day, and I
> alternate between sitting/standing at my desk, and I also just like
> rotating an external 19" lcd depending on the task at hand.).
>

Nice!

> The problem I have is that I haven't found any status-bar like
> programs (eg: xmobar, taffybar) that will keep up with the screen
> adjustments I do.  (gnome-panel worked, but it's apparently being
> phased out, and I'm not particularly happy with gnome dependencies
> anyway.)  I usually end up with a status bar that's offset into the
> middle of the screen after a rotation / addition (taffybar) or, with
> xmobar, the bar eventually disappears entirely.
>
> I think I can probably fix things by tweaking taffybar/xmobar to
> respond to resize commands from xmonad, but I don't know how to detect
> the screen geometry changes within my xmonad source.  This looks like
> the right module to start with:
>
> http://xmonad.org/xmonad-docs/X11/Graphics-X11-Xlib-Extras.html#t%3AEvent
>

It turns out all the good stuff is in Graphics.X11.Xlib.Extras

> but I haven't been enlightened by any of the Event values .. snip ..
>

Assuming you are running darcs xmonad, and assuming root window
configure events signal such changes, I believe you could use something
like (untested):

  fixBars = -- probably something using getCleanedScreenInfo and Display
  -- fixBars could be :: IO () or :: X ()
  -- if you end up in X, change (io u) to u, making
  -- onRescreen :: X () -> Event -> X All

  onRescreen ::  IO () -> Event -> X All
  onRescreen u (ConfigureEvent {ev_window = w}) =
      whenX (isRoot w) (io u) >> return (All True)

  onRescreen _ _ = return (All True)

  someConfig { handleEventHook = onRescreen fixBars }

XMonad.Main runs rescreen on this same event so it's probably what
you're looking for.

Regards,

-Wirt



More information about the xmonad mailing list