How to switch hardware keyboard language?

How to switch hardware keyboard language?

Ed Bartosh
Karma: 679
2009-12-27 19:39 UTC
Hi,

Does anybody know how to get current hw keyboard language and how to
switch between them programmatically?

Here is what I did so far:
1. I could get list of configured layouts by reading gconf variables
/apps/osso/inputmethod/int_kb_layout and
/apps/osso/inputmethod/ext_kb_layout
2. setxkbmap -layout <layout> allowed me to switch keyboard layout to
<layout>. However, it worked quite funny way.
For example if I have English and Russian (us and ru layouts)
configured and English layout active(I can type English) after running
setxkbmap -layout ru sometimes I can type Russian, sometimes I can't!
But if I have Russian layout active and run setxkbmap -layout us it
always switches layout to English, but I can't switch it back to
Russian by pressing Ctrl+Space (or Ctrl+Chr on N810).
3. My attempts to get any info using xkb calls XkbRF_GetNamesProp,
XkbGetState didn't help much. Both calls return the same info
regardless of which layout is active.
4. I was able to switch layouts using XkbRF_SetNamesProp, but it
worked pretty much like setxkbmap.
5. It's also possible to switch layout by setting gconf variable
/apps/osso/inputmethod/int_kb_layout, but if I set it to 'us' it also
stops switching by Ctrl-Space even if I set
/apps/osso/inputmethod/ext_kb_layout to 'ru'

After doing above exercises I came to conclusion that I'm going wrong
way and setting xkb map isn't a proper way to switch languages on
Maemo. After reading sources of several desktop language switchers. I
also understood that xkb extension works differently on Maemo. Bugs
2501 and 3407 from Maemo bugzilla made me think that something might
be even broken in xkb internals. I gave up when I read this in the bug
2501: "The Ctrl+Space on languages other than Russian changes the
input language, not the keyboard layout". At that point I was totally
confused and decided to write this email.

Can anybody help me with this?

--
BR,
Ed
  •  Reply

Re: How to switch hardware keyboard language?

Arkadiy Glazov
Karma: 203
2009-12-27 20:27 UTC
Hi,

Look the head of file /usr/share/X11/xkb/symbols/nokia_vndr/rx-51 and see some answers :)

Also I wrote package xkblayouts-rx51-ru that set russian phonetic hardware layout. You can look Perl script /usr/bin/xkbcustom after install. I use setxkbmap for determinate and switch keyboard layout
  •  Reply

Re: How to switch hardware keyboard language?

Ed Bartosh
Karma: 679
2009-12-27 20:57 UTC
2009/12/27 Arkadiy Glazov <uglobster@gmail.com>:
> Hi,
>
> Look the head of file /usr/share/X11/xkb/symbols/nokia_vndr/rx-51 and see some answers :)
I can't see any answers there, only new questions :(

> Also I wrote package xkblayouts-rx51-ru that set russian phonetic hardware layout. You can look Perl script /usr/bin/xkbcustom after install. I use setxkbmap for determinate and switch keyboard layout

As I understood from your code(I'm not good at Perl though) you're
just reloading xkb map using setxkbmap utility.
What I'm looking for is how to get the current language and how to
switch between them. I've looked into setxkbmap sources and tried to
use it. It didn't work for me, as I explained in my first email.

Answering two simple questions would help a lot:
1. How to determine which language is active at the moment?
2. How to switch between them?
This is pretty much all I want to know :)

--
BR,
Ed
  •  Reply

Re: How to switch hardware keyboard language?

Roman Moravcik
Karma: 614
2009-12-27 21:56 UTC
Hi,

> After doing above exercises I came to conclusion that I'm going wrong
> way and setting xkb map isn't a proper way to switch languages on
> Maemo. After reading sources of several desktop language switchers. I
> also understood that xkb extension works differently on Maemo. Bugs
> 2501 and 3407 from Maemo bugzilla made me think that something might
> be even broken in xkb internals. I gave up when I read this in the bug
> 2501: "The Ctrl+Space on languages other than Russian changes the
> input language, not the keyboard layout". At that point I was totally
> confused and decided to write this email.
>

If I'm not wrong, hildon_im_keyboard_monitor.so library is responsible for this switching of layouts if you press eg. Ctrl+Space. Problem is that library is proprietary.

Regards,
Roman
  •  Reply

Re: How to switch hardware keyboard language?

Emil Biserov
Karma: 11
2010-02-16 22:56 UTC
Solution is very simple - "gconftool-2 -R /apps/osso/inputmethod" & diff output for different languages activated. But way to find it was not so simple. I spent many time by trying get something with Xkb.

> Answering two simple questions would help a lot:
> 1. How to determine which language is active at the moment?
$ gconftool-2 -g /apps/osso/inputmethod/int_kb_level_shifted

> 2. How to switch between them?
$ gconftool-2 -s /apps/osso/inputmethod/int_kb_level_shifted -t boolean false
$ gconftool-2 -s /apps/osso/inputmethod/int_kb_level_shifted -t boolean true

> This is pretty much all I want to know :)
Now you know... Do you working on status icon for h/w keyboard too ?

BRGDS, Emil
  •  Reply