GNOME Bugzilla – Bug 108446
xmodmap vs setxkbmap -- gkb should default to setxkbmap
Last modified: 2004-12-22 21:47:04 UTC
gkb defaults to use xmodmap to set the new layout. I do believe and try to prove now that this is a really bad idea and setxkbmap should be used by default (i.e. setxkbmap should be offered to the users who don't know what xmodmap or setxkbmap means). (However, bug #108406 has to be solved first in order to successfully use setxkbmap with gtk+-2.2.) When adding a new layout, the list of keyboard maps should be generated based on the available xkb layouts, and a setxkbmap command should be generated. When setting the properties of a particular layout, the examples should mention setxkbmap first and xmodmap/gkb_xmmap later. If gkb wants to restore the startup time layout, it should execute 'setxkbmap -v' to query that and later setxkbmap to restore that. My arguments will follow here. But first of all I mention the fact that KDE's keyboard applet uses setxkbmap. gkb's homepage says that 'On a typical Linux system, xmodmap files can be found under the directory /usr/share/xmodmap'. On my system no-one else than gnome-applets itself ships files to this directory. Luckily. Imagine what happened if more desktop environments or applications would ship files here. Imagine what happened if e.g. KDE would use xmodmap too and put its own files here, most likely with conflicting file names and different contents. While themes, icon looks and plenty of other things can be specific to one desktop environment or one setting, there are things that must be unique to all of them. As probably no-one wants to duplicate the timezone or iconv and localedata database found in glibc, instead every application uses the interface provided by glibc, similarly keyboard layouts mustn't be specific to one desktop environment or another. It is a completely brain-damaged idea that gnome-applets ships a set of keyboard layouts, and then why doesn't KDE or icewm or wmaker do so? And what if they all shipped their layouts? Obviously they would all be different, causing a lot of unnecessary troubles to the user. Keyboard layouts mustn't be specific to the taste of Gnome developers, they should be the same as the keyboard layouts in every desktop environment. And the only possible place to store these official layouts is obviously XFree86. Take a look at the keyboard definitions found in XFree and in Gnome. You'll find that xfree's version is much better, much up to date and has more features. For example see the Hungarian layouts. XFree defines 16 variants (2^4), 8 of them are obsolete latin1 mapping, but 8 are fairly usable, and their content is trivial based on their name (e.g. uni_101_qwertz_comma is for 101-key keyboards, qwertz row, and comma on the numpad). gkb offers approx. 3 obsolete and 3 usable Hungarian layouts, where it isn't clear at all which one I should choose and how it will behave. XFree's layouts already include the Euro symbol, while gkb's layouts do not. So I hope that by now you see that XFree has well maintained layout files and it's completely impossible for Gnome to stay up in sync with it, and that it is not the good approach. Layouts should not be maintained at all within Gnome, only in XFree, and Gnome should use those ones. It is only possible with setxkbmap, not with xmodmap. And there is one more, completely different argument against xmodmap. When using xmodmap, you have to know the physical keycodes. These are hardcoded to gkb's xmodmap files, and hence they only work on PC's. Different computers (e.g. a Sun, IBM RS* etc.) have totally different physical keycodes and hence gkb cannot be used at all on these computers, as it loads a nonsense layout. If you think of X as a networking system where different machines can play the role of the server and the client (e.g. the X server where I'm sitting can be a Sun while the X client where Gnome runs can be a PC), you see that it is impossible for the client (e.g. xmodmap or gkb or gnome) to know what physical keycodes the keyboard produce for each key. And hence it is impossible for them to set a correct layout using xmodmap. It is only the X server that knows the type of the keyboard, and so the X server has to be asked to load a particular keymap. And this is exactly what setxmbmap is for. Xmodmap is unable to complete this job because of its purely client side design.
One more reason... Beginning with XFree86-4.3, the Ctrl-Alt-something hotkeys are not hardcoded into X, they are dynamically configurable. After a "setxbmap us" command "xmodmap -pke" prints these: keycode 22 = BackSpace Terminate_Server keycode 67 = F1 XF86_Switch_VT_1 keycode 86 = KP_Add XF86_Next_VMode etc... After loading any of the keymaps shipped with gkb, none of these usual Ctrl-Alt-somehing hotkeys will work. No console switching, (Ctrl-Alt-F1), no forced server reset (Ctrl-Alt-Backspace), etc.
Please, make gkb working correctly with XKB and use libxklavier. For more information see bug 80585 and bug 96215 I think these bugs are related, but I don't know what depends on what :(
Now, it is all done. Closing it.