LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Add a new modifier key (http://www.linuxquestions.org/questions/linux-hardware-18/add-a-new-modifier-key-589698/)

Ekardnam 10-05-2007 12:11 PM

Add a new modifier key
 
Got Compiz Fusion up and running today, sweet. Now I'm planning to dedicate the Caps Lock key to window management, thus turning it to a modifier key.

"Wait a minute", you say, "this has been answered like 10000 times before if not more!" And you are right, I apologize for brining such a common "trick"/question up again; I've search for a while, both here and using Google, but still haven't found a solution.

So what's the problem?

I don't want to switch keys or remap caps lock to an existing key. I want a new modifier key. Obviously, xmodmap is the answer. I ran it and got

Code:

hans@localhost:~$ xmodmap
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift      Shift_L (0x32),  Shift_R (0x3e)
lock     
control    Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Alt_L (0x7d),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3     
mod4        Super_L (0x7f),  Hyper_L (0x80)
mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x71),  ISO_Level3_Shift (0x7c)

After searching a while, I found Hyper_L. Using xev, I learned that the keycode of my caps lock key was 66.

Code:

xmodmap -e 'remove lock = Caps_Lock'
xmodmap -e 'keycode 66 = Hyper_L'
xmodmap -e 'add mod3 = Hyper_L'

Sure enough, when running xev again, it says keycode 66 (keysym 0xffed, Hyper_L). So far so good.

So why are you asking for help then?

Because, apparently, my applications don't like the new key. When trying to map a shortcut in KDE applications, it simply doesn't react when I press the caps lock key (which should have shown as "Hyper").

Better luck with CompizConfig Settings Manager (K version) then? Kind of. I can map actions to "Hyper+something", but when I press the combination, nothing happens.

That's how far I've gotten. It feels like I've made a stupid mistake somewhere, instead of trying for hours and finally realizing it I beg for your help instead.

If the Hyper key isn't any good, I've thought of another possible solution: map caps lock to <Control><Super><Shift><Alt>. Is that possible? So when I press the caps key, it's like pressing the four modifier keys, creating a "new" modifier key.

As always, thanks in advance.

Electro 10-06-2007 05:51 AM

I think X Window System uses its own keymap which may change what you set in bash. If you are using Xorg 7.x, you can use custom key code option in your /etc/X11/xorg.conf file. Also you can place a file in your home directory, so KDE runs it when you log into it. I think KDM, a display manager, also provides a way to set custom key maps. Probably the xorg.conf way will be the best way.

I do not use KDE because it is too bloated, so check its documentation or ask a KDE developer.

Just remember, what you set in virtual terminal will not work for other programs. Every virtual terminal and every program that you run gets its own environment. Linux is a multi-task OS which means it runs many tasks with the same default environment that is separated by other programs.

Ekardnam 10-06-2007 03:38 PM

Quote:

Originally Posted by Electro (Post 2915137)
I think X Window System uses its own keymap which may change what you set in bash. If you are using Xorg 7.x, you can use custom key code option in your /etc/X11/xorg.conf file.

Didn't find much info about it, do you know where I can find more (as in more relevant) information?

Quote:

Originally Posted by Electro (Post 2915137)
Just remember, what you set in virtual terminal will not work for other programs.

Is that really the case with xmodmap? Because I have no problems remapping caps lock to other keys, such as escape.

Right now I wonder if it isn't a KDE issue; Hyper isn't listed as a modifier key under "KDE Modifiers". Does anyone know how to add it there?

uni4dfx 06-25-2009 12:59 PM

I would also like to know this.

smitchel1099 03-20-2011 02:33 AM

how to add a modifier
 
This is an excerpt from the Xmodmap man page in Ubuntu and might be the clue of how to do this:
clear MODIFIERNAME
This removes all entries in the modifier map for the given
modifier, where valid name are: Shift, Lock, Control, Mod1,
Mod2, Mod3, Mod4, and Mod5 (case does not matter in modifier
names, although it does matter for all other names). For
example, ‘‘clear Lock’’ will remove all any keys that were
bound to the shift lock modifier.

add MODIFIERNAME = KEYSYMNAME ...
This adds all keys containing the given keysyms to the
indicated modifier map. The keysym names are evaluated after
all input expressions are read to make it easy to write
expressions to swap keys (see the EXAMPLES section).

remove MODIFIERNAME = KEYSYMNAME ...
This removes all keys containing the given keysyms from the
indicated modifier map. Unlike add, the keysym names are
evaluated as the line is read in. This allows you to remove
keys from a modifier without having to worry about whether or
not they have been reassigned.

oneandoneis2 03-21-2011 06:04 AM

I think you've missed a few steps. I haven't messed around with hotkeys lately, but when I wanted to add a key on Debian Lenny, the full process I used was:

Use xev to find the keycode, which was in this case the standard 115

Edit /usr/share/X11/XKeysymDB so it knows there's a new key for it to deal with on the keyboard:
Start :11000001
added to the end of the file

Create the file /etc/X11/Xmodmap to link the Start key to keycode 115:
keycode 115 = Start

To get xmodmap to actually load the file you just created, near the end of the file /etc/X11/Xsession add:
[ -f /etc/X11/Xmodmap ] && xmodmap /etc/X11/Xmodmap

Hope something in that helps!


All times are GMT -5. The time now is 08:05 PM.