[xmonad] A third border color for the last focused window of a non-active screen

adam vogt vogt.adam at gmail.com
Tue Jun 26 16:13:44 CEST 2012

On Thu, Jun 21, 2012 at 9:52 PM, Mauro Stettler
<mauro.stettler at gmail.com> wrote:
> Hi list
> I have a question regarding the colors of window borders. As far as i
> can see there are the two values normalBorderColor and
> focusedBorderColor in the config, which define the focused and
> not-focused colors of window borders. At my workdesk I have a
> dual-head setup, so I select the two screens with mod-w and mod-e. Now
> every time I select the other screen the window of this screen which
> has been focused when i left the screen gets focused again. So my
> question is, is there any way how I could choose a third color for the
> last focused window of a screen which is not selected at the moment.

Hi Mauro,

It is possible to set the border colour after xmonad sets it. One
example of this already being done in contrib is in
X.L.WindowNavigation [1]. The parts to focus on are the
definitions/usages of `sc :: Pixel -> Window -> X ()' and
stringToPixel. Between those two, you can write a function that sets a
border color.

Once you have that function, you can set the border colour on the
unfocused screen with a logHook. You can get the Window that
corresponds to the unfocused screen(s) using:

focusOfVisible :: X [Window]
focusOfVisible = gets (mapMaybe (fmap W.focus . W.stack . W.workspace)
.  W.visible . windowset)

Then just put the pieces together to write that logHook:

setBC :: String -> X ()
setBC col = do {
  d <- asks display;
  px <- stringToPixel d col;
  ws <- focusOfVisible;
  mapM_ (sc px) ws }

It's quite possible that there are some errors, since I didn't test
this code. Even if it does work, it could be improved by keeping track
of which windows have the different colour set, for example by storing
the list of windows whose borders do get set in

[1] http://xmonad.org/xmonad-docs/xmonad-contrib/src/XMonad-Layout-WindowNavigation.html


More information about the xmonad mailing list