LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-22-2005, 04:18 PM   #1
TomalakBORG
Member
 
Registered: Dec 2004
Location: Maryland
Distribution: SuSE / Gentoo
Posts: 245

Rep: Reputation: 30
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
 
Old 04-23-2005, 12:51 PM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
http://wmalms.tripod.com/#XHKEYS

that should do the trick
 
Old 04-23-2005, 04:28 PM   #3
TomalakBORG
Member
 
Registered: Dec 2004
Location: Maryland
Distribution: SuSE / Gentoo
Posts: 245

Original Poster
Rep: Reputation: 30
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?
 
Old 04-23-2005, 06:18 PM   #4
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
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
 
Old 04-23-2005, 06:41 PM   #5
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 61
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 '
 
Old 04-24-2005, 02:36 AM   #6
alcibiades
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Rep: Reputation: 0
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
 
Old 04-24-2005, 11:54 AM   #7
TomalakBORG
Member
 
Registered: Dec 2004
Location: Maryland
Distribution: SuSE / Gentoo
Posts: 245

Original Poster
Rep: Reputation: 30
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?
 
Old 04-24-2005, 01:45 PM   #8
TomalakBORG
Member
 
Registered: Dec 2004
Location: Maryland
Distribution: SuSE / Gentoo
Posts: 245

Original Poster
Rep: Reputation: 30
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'
 
Old 04-24-2005, 03:27 PM   #9
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

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

Brian1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mapping Keyboard Special Keys(some success at long last) RedShirt Suse/Novell 0 11-13-2005 09:43 PM
mapping extra function keys in Gnome 2.2 evano Slackware 1 09-08-2005 05:17 PM
mapping non standard keyboard keys gravesb Linux - Hardware 13 08-31-2005 07:16 PM
mapping the keyboard scroll whell to emulate + & - keys micker Linux - Software 2 01-25-2005 07:15 AM
mapping keyboard keys fedetxf Linux - Newbie 1 03-23-2004 08:49 PM


All times are GMT -5. The time now is 12:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration