LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Mapping unused key as Super-key (https://www.linuxquestions.org/questions/ubuntu-63/mapping-unused-key-as-super-key-4175512672/)

CVAlkan 07-29-2014 07:42 PM

Mapping unused key as Super-key
 
I'm using a "real" keyboard from a few decades ago (a Northgate Omnikey Ultra) that has served me well through many PCs over the years but, as with all keyboards of that generation, it has no "super" ("Windows") key. It has an unused key that I would like to remap to serve as a "Super" Key, but none of the documentation I've located seems to apply to Ubuntu 14.04; indeed most of it refers to locations and utilities that don't exist in Ubuntu 14.04.

The key in question produces a keycode of 120 according to the following xev output:

KeyPress event, serial 37, synthetic NO, window 0x4000001,
root 0x2c5, subw 0x0, time 48472296, (-32,-123), root:(859,363),
state 0x10, keycode 120 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4000001,
root 0x2c5, subw 0x0, time 48472382, (-32,-123), root:(859,363),
state 0x10, keycode 120 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

So I added and commented out lines in /usr/share/X11/xkb/keycodes/xfree86 as below:
// Microsoft keyboard extra keys
// Comment and addition on 2014-07-25 to use unused physical Omni Key as a replacement for the Windows Key
// <LWIN> = 115;
<LWIN> = 120;
. . .
// Commented out on 2014-07-25 to use actual Omni Key as a Windows Key
// <FK15> = 120;

After rebooting, the key is recognized as "Super_L" as shown in the xev output below:

KeyPress event, serial 37, synthetic NO, window 0x4200001,
root 0x2c5, subw 0x0, time 49142127, (241,-71), root:(1132,415),
state 0x10, keycode 120 (keysym 0xffeb, Super_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4200001,
root 0x2c5, subw 0x0, time 49142270, (241,-71), root:(1132,415),
state 0x50, keycode 120 (keysym 0xffeb, Super_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

I assume from this that I chose the correct file to edit from the usr/share/X11/xkb/keycodes directory (how, by the way, would I have been able to determine which file was loaded/used when 14.04 starts? - I just pciked that as most likely by browsing through the many available.).
Pressing the key, however, does absolutely nothing. The Keyboard facility in System Settings seems to offer no method for assigning keys - only for assigning functions to existing keys.

Running "xmodmap -pm" gives the following output:

shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x78), Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)

Does this mean that the "Super_L" key is only a modifier? What I want is the stock functionality of the key. Should I comment out or remove the mod4 line?

The key I'm attempting to map, by the way, is labelled "Omni" and is located in the center of a separate grouping (not the "numeric keypad") laid out like this, and with the keycodes reported by xev:
________________________________________
| Home | Up Arrow | PageUp |
| 110 | 111 | 112 |
|----------------------------------------|
| Left Arrow | OmniKey | Right Arrow |
| 113 | 120 | 114 |
|----------------------------------------|
| End | Down Arrow | PageDown |
| 115 | 116 | 117 |
|----------------------------------------|
| Insert | Delete |
| 118 | 119 |
----------------------------------------

I looked under /usr/share/X11/xkb/symbols to see if there was a corresponding xfree86 mapping, but there was none, so the "us" mapping seems to be the one in use. The Home, Arrow and Page Up/Down keys work as expected, although they have different keycodes than the ones on the numeric keypad. I am guessing that adding a line to the "us" file such as:

key <LWIN> { [ ??, ??, ??, ?? ] };

might do the trick, but what would I enter in place of the ?? characters (i.e. where are the definitions of values such as "minus" "underscore" and such, or what would it be for windows key functionality?

Since the Ubuntu System Settings didn't provide anything useful for addressing this, I followed another recommendation to use something called "gnome-control-center' from the command line. Ubuntu helpfully informed me that this was not available on my system, but could be installed by typing "sudo apt-get install gnome-control-center". So I did that, and it went through the usual process, after which I was able to launch this from the command line.

Surprise, surprise. Gnome Control Center is, in fact, the utility presented by the Systems Setting choice on the main screen. Of course, now I'm terrified that if I "uninstall" it (as it's obviously the same thing and therefore redundant) some things will be inadvertantly removed.

I've run dconf-editor, and found the following sections (recommended by a few folks), but these all just seem to duplicate the entries in the GUI tools, and have no apparent way to tell the system that my Omni key is really a "Super" key:
org | onboard | keyboard section
org | gnome | desktop | wm | keybindings
org | gnome | libgnomekbd | settings-daemon | peripherals | keyboard

Other suggestions included adding an .Xmodmap in my home directory with the line "keycode 120 = Super_L" (did nothing even after reboot) and creating an .xsessionrc with the line "xmodmap -e "keycode 120 = Super_L" (also did nothing even after reboot.

I also tried manually entering the two commands below, which was recommended on some sites, but it didn't seem to have any effect either.
xmodmap -e "add mod4 = Super_L"
xmodmap -e "keycode 120 = Super_L" -e "add mod4 = Super_L"

Can anyone tell me what I'm missing? Or has no one figured out yet what changes were made in Ubuntu 14.04 to keep us all guessing? (All these suggestions on the web apparently worked for the posters, but all of them seem to be for earlier versions than 14.04).

notKlaatu 07-30-2014 10:26 PM

I would try placing this in ~/.Xmodmap:

Code:

clear mod4
keycode 120 = Hyper_L
add mod4 = Hyper_L

I'm using Hyper_L because I'm guessing that it is not in use.

Then do

Code:

xmodmap ~/.Xmodmap
and see what happens.

CVAlkan 07-31-2014 08:14 AM

Thanks for the suggestions ...

I tried what you suggested as well as variations using Super_L instead of Hyper_L and Unity just simply doesn't recognize the. It's only because of xev (and the fact that I can easily remap the key in Windows) that I know the keyboard works. I'll try it later with a "live-cd" to see if will work with a "naked" system (i.e. in case I've just mashed something along the way).

notKlaatu 07-31-2014 03:07 PM

Yeah, could be Unity intervening, I guess. I am on Fluxbox and KDE, and my Xmodmaps work. Then again, I don't have an 'Omni' key, so who knows...!


All times are GMT -5. The time now is 05:16 AM.