Page 1 of 2
One keyboard layout too many in applet
Posted: Sat Mar 06, 2010 12:17 pm
by Sphinx
Hey all, I'm using LXDE with lxpanel 0.5.5 on Slackware, and have trouble getting keyboard layouts to work as I want them to.
I'm on Slackware 13, using LXDE (lxpanel 0.5.5), and would like to switch between the English and German layout. So far I set up a hal policy file to define these rules:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.keymap">
<append key="info.callouts.add" type="strlist">hal-setup-keymap</append>
</match>
<match key="info.capabilities" contains="input.keys">
<merge key="input.xkb.rules" type="string">base</merge>
<merge key="input.xkb.model" type="string">evdev</merge>
<merge key="input.xkb.layout" type="string">us,de</merge>
<merge key="input.xkb.options" type="string">grp:alt_shift_toggle</merge>
<!--<merge key="input.xkb.variant" type="string">,nodeadkeys</merge>-->
</match>
</device>
</deviceinfo>
The problem is, the applet shows three options: A US flag, a German flag, and the text "en_US". Where does this third thing come from? Besides, it's messing up the ordering, because I get a German layout with a US flag on the applet and vice versa.
I ditched the hal policy file and generated an xorg.conf with the same rules, but that didn't help either. This is rather annoying, because I managed to set this up correctly a year ago, but after a system update lost the configuration and can't get it to work again as it did.
Where's this "en_US" coming from, and how can I rid myself of it?
Thanks,
-A
Re: One keyboard layout too many in applet
Posted: Sat Mar 06, 2010 6:44 pm
by Marty Jack
Kindly run this for me and post the output. Compile with cc -lX11 -o xkbtest xkbtest.c and you will need the X11 development headers.
Code: Select all
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#include <X11/Xatom.h>
#include <X11/XKBlib.h>
#include <stdio.h>
int main(int argc, char * * argv)
{
Display * display = XOpenDisplay(NULL);
/* Initialize Xkb extension if available. */
int opcode;
int maj = XkbMajorVersion;
int min = XkbMinorVersion;
int xkb_event_base;
int xkb_error_base;
if ((XkbLibraryVersion(&maj, &min))
&& (XkbQueryExtension(display, &opcode, &xkb_event_base, &xkb_error_base, &maj, &min)))
{
/* Allocate a keyboard description. */
XkbDescRec * xkb_desc = XkbAllocKeyboard();
if (xkb_desc != NULL)
{
/* Read necessary values into the keyboard description. */
XkbGetControls(display, XkbAllControlsMask, xkb_desc);
XkbGetNames(display, XkbSymbolsNameMask | XkbGroupNamesMask, xkb_desc);
if ((xkb_desc->names != NULL) && (xkb_desc->ctrls != NULL) && (xkb_desc->names->groups != NULL))
{
/* Get the count of available keyboard layouts. */
int group_count = xkb_desc->ctrls->num_groups;
printf("%d\n", group_count);
/* Get the group name of each keyboard layout. */
Atom * group_source = xkb_desc->names->groups;
char * group_names[XkbNumKbdGroups];
int i;
for (i = 0; i < XkbNumKbdGroups; i += 1)
{
char * group_name = NULL;
if (group_source[i] != None)
group_name = XGetAtomName(display, group_source[i]);
printf("%s\n", ((group_name != NULL) ? group_name : "-"));
}
/* Get the symbol name of all keyboard layouts.
* This is a plus-sign separated string. */
if (xkb_desc->names->symbols != None)
{
char * symbol_string = XGetAtomName(display, xkb_desc->names->symbols);
if (symbol_string != NULL)
printf("%s\n", symbol_string);
}
}
}
XkbFreeKeyboard(xkb_desc, 0, True);
}
XCloseDisplay(display);
return 0;
}
Re: One keyboard layout too many in applet
Posted: Sat Mar 06, 2010 9:06 pm
by Sphinx
Here's what I got:
Code: Select all
bass@Slackware:~/Desktop$ ./xkbtest
3
USA
Germany
-
-
pc+us+de:2+inet(evdev)+group(alt_shift_toggle)
Seems there's this extra group denoted by "pc". What to do about it that I only have us and de?
Thanks for taking the time!
Regards,
-A
Re: One keyboard layout too many in applet
Posted: Sat Mar 06, 2010 9:39 pm
by Marty Jack
The "pc" and the "inet(evdev)" are always there. It is the "3" that is confusing the code, and I can fix it. Thanks for doing the test.
Re: One keyboard layout too many in applet
Posted: Sat Mar 06, 2010 9:48 pm
by Sphinx
You're welcome, and thanks again. So is this merely a bug in the latest lxpanel version?
-A
Re: One keyboard layout too many in applet
Posted: Sat Mar 06, 2010 11:11 pm
by Marty Jack
You could argue about where the bug is. If I set up your case and run it on my system, I get :
Code: Select all
martyj:~/GT$ ./xkbtest
2
USA
Germany
-
-
pc+us+de:2+inet(evdev)+group(alt_shift_toggle)
You can see that the X server is reporting inconsistent values on your system.
In any event, this is in some code that was lifted from another desktop environment a long time ago, so it was not recently introduced.
Re: One keyboard layout too many in applet
Posted: Sun Mar 07, 2010 4:23 pm
by Marty Jack
Fixed in git commit 447ea0f5dcafb335348aef764a7d9c45febddc0b.
Re: One keyboard layout too many in applet
Posted: Sun Mar 07, 2010 7:04 pm
by Sphinx
Thanks, I'll check it out
Best regards,
-A
Re: One keyboard layout too many in applet
Posted: Sun Mar 07, 2010 7:25 pm
by Sphinx
Well, now the situation has improved a bit, now I get only flags, and they display the correct layout (which is already a good step forward), but I still have two US groups. Maybe the bug lies elsewhere, in another package or configuration, if the same policy file gives you the correct result.
Thanks a lot for this fix though!
-A
Re: One keyboard layout too many in applet
Posted: Sun Mar 07, 2010 7:49 pm
by Marty Jack
As I mentioned earlier your X server is reporting the wrong information. I might next investigate the version of your X server (that's at the top of /var/log/Xorg.0.log). But if you can continue working successfully, you may wish to leave well enough alone. I am surprised that you are seeing more than two layouts because the code that is in there now should be concluding that you have only two. Maybe if you are using your group toggle key, the server will go to the nonexistent group. You should get the correct result if you click or scroll-wheel on the flag itself.
You should also be getting tooltips that say "USA" and "Germany" when you have the flags being displayed. You should also be able to select "Text" display in the right click Settings menu and see US and DE. All of that happened when I tested it.
I could and did test this fix only with fault insertion because my X server is reporting consistent information.