LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   mapping custom keys (https://www.linuxquestions.org/questions/linux-general-1/mapping-custom-keys-316179/)

TomalakBORG 04-22-2005 04:18 PM

mapping custom keys
 
Hey guys - here's the deal.

I have an internet keyboard, and subsequently have a bunch of extra keys for volume, play controls, etc.. So I wanted to learn to map these keys, and start with the volume controls. I have ran xev - and learned that the volume wheel has two key codes, one going up and one down. So how would I map these key codes to aumix -v +10 and aumix -v -10? (although I would use the same format to map all the other keys I wanted I suppose) I just want to A) learn to do this, and B) pimp out my X so nothing is using the mouse to launch things and whatnot.

I suppose another part of this question is what's the difference between mapping keys for fluxbox, and mapping keys for all of X. See, things like volume control should be in all of X (/etc/xorg.conf?) and things like launching apps should be within fluxbox. I only know this because my 'nix savy friend is bragging about how he never launhes anything from a menu anymore. Then he wouldn't tell me how.. lol. Any ideas? -Bill

SciYro 04-23-2005 12:51 PM

http://wmalms.tripod.com/#XHKEYS

that should do the trick

TomalakBORG 04-23-2005 04:28 PM

That's a pretty cool app, but I was wondering about the way to manual do it all. I was really trying to learn how most people add in key functions. Say, what is the procedure for binding a key to a command?

SciYro 04-23-2005 06:18 PM

there is non that i know of, as far as i can tell, X doesn't bind keys to events, you need a extra program running to listen for those keys, and that program will bind keys to functions

Brian1 04-23-2005 06:41 PM

Check out these post
http://www.linuxquestions.org/questi...18#post1483618
http://www.linuxquestions.org/questi...388#post536388
http://www.linuxquestions.org/questi...hreadid=260740

There are many other post here on the subject as well. If you every figure out the question I asked in the last post let me know. I myself like writing the scripts and then using the khotkeys in the Control Center of KDE to finsih the work. I guess I am getting lazy in my old age.

Brian1
Google the Linux way at ' http://www.google.com/linux '

alcibiades 04-24-2005 02:36 AM

How to swap keys
 
I have been trying to do something similar, and think this is how to do it.

The first step is to find out the keycode for the key you want to put a new function on. This will be one number, even if the key can send multiple characters. You do this very simply: run xev and then hit the key. There will be two entries, one for the depress and one for the release, and they will have the same keycode.

Next, you have to find out what the keysym is for the command you want the character to send. I only know how to do this for keys that already work someplace on the keyboard, and that is to depress them, also using xev. I think if you look up the xmodmap manual, there is a way to associate commands with keycodes. Or there may be other ways of looking up the exact names for keysyms. For example, the double inverted comma is called 'quotedbl' whereas the single one is called 'apostrophe'. You have to get these names exactly right.

Next you create a text file, and this is in the form

keycode [keycode number] = [keysym name1] [keysymname2] [keysymname3] [keysymname4]

and as many lines as you want to change keys.

The result will be, that keysyname1 will become the result when the key is pressed without a shift, and keysymname2 will become the result when it pressed shifted. The last two possibilities, 3 and 4 are with other modifiers pressed - the xmodmap manual page explains.

Now you open a terminal, become su -, and run

xmodmap [full path to text file].

Lo and behold, the keys will now do just what you told them to do.

Suppose you have a disaster when doing this, and suddenly find half your keyboard no longer works, which happened to me. You then open your hardware configuration panel and set the keyboard back to what it was. In Mandrake this is part of HardDrake, in Suse you use the X configurer. No idea what you do in the less graphical distros. But find out before starting!

It is in fact really simple once you understand what to do. It takes hours however for the naive to figure out exactly what to do.

I have not yet verified that changes done like this survive reboots, but getting xmodmap to do this at startup must be pretty trivial if not.

Cheers

Al

TomalakBORG 04-24-2005 11:54 AM

Ok, I think I'm onto it - here's what I've done.

I created a file /etc/X11/Xmodmap
here it is:

keycode 176 = /opt/volumekeys/volumeup
keycode 174 = /opt/volumekeys/volumedown

I made the two scripts in /opt/volumekeys, but it seems like they aren't executable. I'v e tried /opt/volumekeys/volumeup and just volumeup in the command line, but they don't work. I do xmodmap /etc/X11/Xmodmap and it gives me an error.

What am I doing wrong?

TomalakBORG 04-24-2005 01:45 PM

A side note - the command 'sh /opt/kde/volumekeys/volumeup (or volumedown)' works!
However in the xmodmap file when I do xmodmap /etc/X11/Xmodmap (the lcoation of my file) it gives me the error 'Bad keysym name in keysym list' and it tells me whatever I put in. eg; Keycode 176 = sh /opt/volumekeys/volumeup the error is 'Bad keysym name in keysym list sh; Bad keysym name in keysym list /opt/volumekeys/volumeup'

Brian1 04-24-2005 03:27 PM

You need to give the scripts executable tags. Run this command. ' chmod +x name_of script '

Brian1


All times are GMT -5. The time now is 04:34 AM.