Regular readers will know by now, that I try to keep you guys happy
– perhaps not quite to the level that the wonderful MaryMary
does, but hey, I’m in engineering not marketing, and I just don’t have
the same contacts for obtaining free
as she does… (hmm, have to start working on that one)

David wrote a comment on a piece I posted a while back about Spanish
(astute readers will have noticed that post wasn’t about
keyboards at all, instead being a bit of a whinge on my part about
fooling the most popular search engine in the world, but just to be
nice, I ended it with a bit of free tech support about keyboard layouts
in Solaris, which the aforementioned search engine seems to have latched
on to – curse it! This post is only making things worse ! :-)).
David was complaining about the complexity of setting up a Dvorak
layout in Solaris. I agree with him 100% : it’s not easy.

First, a confession – I don’t use a Dvorak keyboard, not because I don’t
believe in the benefits that switching might bring, just that I can’t
spend a huge amount of time re-tuning my fingers to learn a new layout.
People who’ve seen me type know that I have a somewhat erratic
keyboarding style – I tend to go for the “high speed and very low
approach (my most typed key turns out to be
BackSpace, I believe) The way I look at it, I’m having a whale of a time
typing lots of letter sequences that don’t get the attention they
deserve in the English language, so I’m doing the world a good turn.
(ahem). Not switching to the better techonology is sort of out of
character for me : I always run the latest bleeding-edge Solaris builds
I can get my hands on, I have no emotional attachment to any particular
piece of software, particularly text editors or email clients, which
tend to bring out the zealot in a lot of people (though it was
borderline for me with the old OpenWindows mailtool, but I’m over that
now, having used elm, pine, Dtmail, HotJava Views (which I loved),
Mozilla, Thunderbird, Mac OSX, Mulberry and Evolution along the
way… Evo seems to be the one I’ve settled on for the moment)

So software, yes – I’m there, but keyboards, nope – still in the dark
ages I’m afraid. The nearest I ever get to switching keyboard layouts
these days is when I have to use a US keyboard that might be attached to
a Sun
in some meeting room or other, and that’s a real pain. In those
cases, xmodmap comes to the rescue, and I use the following to bring
some sanity :

cat > /tmp/tim.xmodmap <&ltEOF
xmodmap < tmp/tim.xmodmap
echo Swapped Caps Lock and \(left\) control key
echo made the key to the left of F1 work as Escape
rm /tmp/tim.xmodmap

Seriously, what were those Americans thinking, putting the caps-lock
where control should be ? It was different back in my Solaris
Localisation Testing days (wow, was that really 10 years ago !?) I’d
come across new keyboard layouts all the time back then. Testing
keyboard layouts was one of the things we did in the European
Localisation Centre, where keyboard-types were rotated along with the
usual test-cycle of installing and running Solaris in different locales.
I remember that some layouts seemed to be going out of their way to make
life difficult for the UNIX user (I mean, putting the ‘/’ character on
the “Shift-7” position ? Xmodmap came to the rescue there, whenever we
needed to do stuff on the command line)

Thing is though, I’m not sure xmodmap is a good thing to use to switch
entire keyboard layouts : remapping the odd key here and there is fair
enough, but changing all of them ? Ouch. Jamie
agrees with me it seems, he says :

Although this may seem like a simple issue it is in fact one of the most
complicated/convoluted things about X Windows – “If you’re thinking that
this is all senselessly complicated… you’re` right” – Jamie Zawinski,
author of xkeycaps.

So, xmodmap isn’t making things very much easier. I’m not sure things
have got a whole lot better since, to be honest. I freely admit to not
completely understanding
the new Xorg keyboard layout stuff
but I’m starting to dabble.
However, getting back to the point (there is one in here somewhere,
struggling to get out) – here’s how to swap the keyboard layout in
Solaris 10.

For some reason, we’re not shipping a utility that comes with the
standard Xorg distribution called setxkbmap.
Inside the GNOME Keyboard Indicator, which you get by right-clicking on
the GNOME Panel, select “Add to panel”, “Utility
-> Keyboard Indicator”
, there’s options for changing the
keyboard layout. Right click on this panel application, select
“Preferences” and you’ll see this :

Gnome keyboard indicator preferences screenshot

This shows the list of keyboards I’m interested in : you’ll notice that
each layout I have added to the list has “xkb keymap”
at the end of it. It seems that the keyboard indicator applet tries to
use setxkbmap to switch layouts if you’ve selected an xkb
keymap, and uses xmodmap otherwise. Of course, since we don’t bundle
setxkbmap (yet?) we get the weird error dialog :

Gnome keyboard indicator preferences error dialog screenshot

This is another example of a dialog box that doesn’t really help : I’ve complained
about these sort of things before
, guess it’s time to file another

If you have setxkbmap, just drop it somewhere in your $PATH, and
everything should be alright – the layout switcher will use it if you
select an xkb layout. I’ve compiled a binary
of setxkbmap
on my laptop, so you’re welcome to use it if you like.
Anyway, this post was just to point out, that you can change keyboard
layouts pretty easily in Solaris now with JDS/GNOME, assuming you’ve got setxkbmap
and use the keyboard layout switcher. Messing around with xorg.conf
will work as well, though that’s changing the layout for all users of
your machine, which may or may not be what you intended. Hope this helps

timf@argentum[504] digest -a md5 bin/setxkbmap

By the way, if you’ve updates or corrections on any of the above,
I’d love to hear about it : just add them to the comments, and I’ll fix
anything I’ve got wrong in the main body of the post.