[Xmonad] xmonad localisation

Mats Jansborg mats at jansb.org
Mon Aug 13 18:05:17 EDT 2007

Hello list,

I have some small patches as well as some questions regarding
localisation of xmonad, I'm sorry if this runs a little long.

Attached is a patch to rewrite David Roundy's NamedWindow using
getTextProperty and wcTextPropertyToTextList, which makes it aware of
the user's locale. I couldn't find these functions in the existing X11
bindings or in X11-extra so I have attached a second patch for
X11-extras that adds them as well as the the TextProperty structure.

To make these patches do anything useful, xmonad also needs to call
setlocale at some point. It is natural to do this first thing in main,
and it is trivial to add except I don't think setlocale or the category
constants are in the standard libraries, so the ffi and hsc2hs or
similar is needed.

In fact, applying these patches without calling setlocale will stop
some titles that are now fetched correctly from working, namely those
that are in ISO-8859-1 but not ASCII, in effect setting the locale to
C, so don't do that. Note also that the patch assumes wchar_t =
Data.Char, i.e. that withCWString works correctly. This is often true
(always in glibc, I think) but not by any means guaranteed. Another
choice would be to use XmbTextPropertyToTextList and keep the title as
an opaque byte array. This is nice as long as you don't need to
interpret it as a string at which point you need something like iconv.

In addition to this, everything that displays text needs to be changed
to be locale-aware. This applies to xmonad itself when it prints log
messages to stderr without encoding them, but maybe this isn't such a
pressing issue to address as it is intended for debugging. More
important are extensions that draw text, window titles in particular. I
think these should be changed to use X(mb/wc)DrawString, xft, pango or
some other locale-aware method.

I have some patches that modify David Roundy's Decoration and Tabbed
modules to use a small xft binding I made, here's a screen shot:


I have used these for a couple of days now and they seem to work, but
I don't propose to apply them for several reasons:
 * they break anything using Decoration
 * they introduce a dependency on xft which clearly shouldn't be a
   hard requirement for building xmonad
 * some people don't like anti-aliasing, I tend to agree at small
   resolutions/font sizes

If there's interest I can post them anyway for people to play with.

How is the the organisation of xmonad supposed to account for extensions
such as these that need to be linked with additional libraries? It seems
any such extensions must patch not only XMonadContrib but also core
xmonad to account for the build process, or is there some way around

/Mats Jansborg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getname.patch
Type: text/x-patch
Size: 39371 bytes
Desc: getname patch
Url : http://www.haskell.org/pipermail/xmonad/attachments/20070814/77c03825/getname-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: textprop.patch
Type: text/x-patch
Size: 5877 bytes
Desc: textprop patch
Url : http://www.haskell.org/pipermail/xmonad/attachments/20070814/77c03825/textprop-0001.bin

More information about the Xmonad mailing list