|
Home > Archive > Unix Programming > October 2005 > How to determine current keyboard layout?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to determine current keyboard layout?
|
|
| Gaurav Jain 2005-10-24, 3:48 pm |
| Hi,
I could not find a way to determine the current keyboard layout on Linux. I
need to do some conditional handling for Vietnamese keyboard input.
Is there an API that I can use (any generic Linux API). I want something in
line with the Win32 API called "GetKeyboardLayout()".
Thanks,
Gaurav
| |
| Pascal Bourguignon 2005-10-24, 3:48 pm |
| "Gaurav Jain" <gaurav.anywhere@gmail.com> writes:
> Hi,
>
> I could not find a way to determine the current keyboard layout on Linux. I
> need to do some conditional handling for Vietnamese keyboard input.
>
> Is there an API that I can use (any generic Linux API). I want something in
> line with the Win32 API called "GetKeyboardLayout()".
xmodmap
eg.: xmodmap -pk
or: xmodmap -pke
--
__Pascal Bourguignon__ http://www.informatimago.com/
In deep sleep hear sound,
Cat vomit hairball somewhere.
Will find in morning.
| |
| Rich Gibbs 2005-10-24, 3:48 pm |
| Gaurav Jain said the following, on 10/19/05 07:00:
> Hi,
>
> I could not find a way to determine the current keyboard layout on Linux. I
> need to do some conditional handling for Vietnamese keyboard input.
>
> Is there an API that I can use (any generic Linux API). I want something in
> line with the Win32 API called "GetKeyboardLayout()".
>
In Linux, unlike Windows, the GUI (almost always the X Window System, or
X) is a separate module from the OS. It is perfectly possible, and
frequently done for servers, to run Linux without any GUI at all. SP
the first thing to keep in mind is that what is going on with X is not
necessarily what happens with a console terminal.
I'll assume that you're interested in X (the GUI). Pascal has mentioned
xmodmap(1) elsewhere in this thread. You might also check to see if
your system has the xkbprint(1) command: that will output a file
containing a PostScript keyboard map.
If you want to manipulate these from within an application, you will
need to look at the documentation for the X library routines:
===
NAME
XChangeKeyboardMapping, XGetKeyboardMapping, XDisplayKeycodes,
XSetModifierMapping, XGetModifierMapping, XNewModifiermap,
XInsertModifiermapEntry, XDeleteModifiermapEntry, XFreeModifierMap
XModifierKeymap - manipulate keyboard encoding and keyboard encoding
structure
SYNTAX
int XChangeKeyboardMapping(Display *display, int first_keycode,
int keysyms_per_keycode, KeySym *keysyms, int num_codes);
KeySym *XGetKeyboardMapping(Display *display, KeyCode
first_keycode, int keycode_count, int *keysyms_per_keycode_return);
int XDisplayKeycodes(Display *display, int
*min_keycodes_return, int *max_keycodes_return);
int XSetModifierMapping(Display *display, XModifierKeymap
*modmap);
XModifierKeymap *XGetModifierMapping(Display *display);
XModifierKeymap *XNewModifiermap(int max_keys_per_mod);
XModifierKeymap *XInsertModifiermapEntry(XModifierKeymap
*modmap,
KeyCode keycode_entry, int modifier);
XModifierKeymap *XDeleteModifiermapEntry(XModifierKeymap
*modmap,
KeyCode keycode_entry, int modifier);
int XFreeModifiermap(XModifierKeymap *modmap);
===
The complete man page for XFree86 is at:
<http://www.xfree86.org/4.4.0/XGetKeyboardMapping.3.html>
Similar documentation is available from X.org also:
<http://www.x.org/X11R6.8.2/doc/>
--
Rich Gibbs
richg74@gmail.com
"You can observe a lot by watching." -- Yogi Berra
|
|
|
|
|