LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 08-22-2005, 11:43 PM   #1
gravesb
Member
 
Registered: May 2005
Distribution: Suse 9.3, Gentoo
Posts: 87

Rep: Reputation: 15
mapping non standard keyboard keys


I have a keyboard with volume control and some other random buttons that I would like to make productive. I have tried to update it through the configuration tool in KDE, and looked around forums on this site, but no solution seems to work. I am running SUSE 9.3. Will it require another driver, or is there a simple .config file that I am unaware of? Also, how do I enter the keys? I tried to type in raw data into OpenOffice, but I received symbols. Not sure if that will translate into a .config file.
 
Old 08-22-2005, 11:56 PM   #2
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
Run xev in the console and push the keys, grab the keycode from the output.

Take that keycode (for example keycode 223) and make this file: ~/.xmodmap

Edit that file to look something like this:

keycode 223 = F13


Then, check your specific Window Manager for these details, bind that F13 key to a command. Activate that modmap by typing `xmodmap ~/.xmodmap` in your terminal.

If you would like scripts to increase, decrease, and mute your volume, let me know and I will paste them here for you.
 
Old 08-28-2005, 07:53 PM   #3
gravesb
Member
 
Registered: May 2005
Distribution: Suse 9.3, Gentoo
Posts: 87

Original Poster
Rep: Reputation: 15
Please do.
 
Old 08-28-2005, 08:08 PM   #4
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
Mute Script:
Code:
      #! /bin/bash

      declare -r TEMPVOLFILE="~/volume.tmp"
      declare -r CURRENTVOLUME=$(amixer get Master | grep 'Mono:' | cut -d' ' -f5)
      declare -i NEWVOLUME

      if [ "${CURRENTVOLUME}" == "0" ]
        then
      if [ -f ${TEMPVOLFILE} ]
        then
                NEWVOLUME=$(cat ${TEMPVOLFILE})
      else
                NEWVOLUME=50
       fi
       amixer set Master ${NEWVOLUME}
      else
       echo ${CURRENTVOLUME} > ${TEMPVOLFILE}
       amixer set Master 0
      fi
      exit 0
That makes the file volume.tmp in your home directory and stores the current volume level of the Master line in it for when you want to unmute (it doesn't work like Windows, there is no real mute/unmute for Linux sound). It then sets the volume to 0, when you press the mute key again, it grabs the number from the file and sets it, if the file is gone, it sets it to a default of 50, or 50%.


Volume Up:
Code:
      #! /bin/bash

      amixer set Master 1+
      exit 0
Adds 1 to the current volume.


Volume Down:
Code:
      #! /bin/bash

      amixer set Master 1-
      exit 0
 
Old 08-28-2005, 08:42 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
Since using KDE what do want to map the keys to do. Look over the following threads for help.

http://www.linuxquestions.org/questi...12#post1707612
http://www.linuxquestions.org/questi...388#post536388
http://www.linuxquestions.org/questi...18#post1483618


Info I have written down in my notes about KDE and extra keys
* Add the following to /etc/X11/Xmodmap for front volume buttons
keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume
keycode 178 = XF86WWW
keycode 236 = XF86Mail

Restart new mapping ' xmodmap /etc/X11/Xmodmap (as root)
Goto kmenu. Goto ThunderBird and select shortcut key at bottom. Hit the mail button it will say XF86Mail.


XF86 is defined in file:///usr/X11R6/include/X11/XF86keysym.h
Other info in file:///usr/X11R6/include/X11/keysymdef.h

Now you don't have to match keycode number with and XF86* option As long as you know the code then something close to what you want it to do. What it amounts to one and call keycode=178 XF86Mail if you want.


Scripts:
For mute scripts require running this command Run ' aumix -f ~/.aumixrc ' to set aumix saving point. Also mute requires 3 scripts volumemute, volumemute1, and volumemute2. The last two rewrite the first one to be ready for the next press.

I need to look over the above post from flower.Hercules and maybe can make it into one script file. I just write simply scripts and need to spend time to understand using other commands in scripts to make chooses.

file:///storage1/Multimedia/volumekeys/volumedn
Code:
#!/bin/sh
aumix -v -5 -S
file:///storage1/Multimedia/volumekeys/volumedn1
Code:
#!/bin/sh
aumix -v -1 -S
file:///storage1/Multimedia/volumekeys/volumemute
Code:
#!/bin/sh
# copy of volumemute2
# This commands saves all current levels to ~/aumixrc
aumix -S
# This command turns master volume to off to 0 percent
aumix -v0
# This command copys the file volumemute1 to volumemute to be ready for the next press
cp /opt/volumekeys/volumemute1 /opt/volumekeys/volumemute
file:///storage1/Multimedia/volumekeys/volumemute1
Code:
#!/bin/sh
# This loads the saved levels of all channels
aumix -L
# This command copys the file volumemute2 to volumemute to be ready for the next press
cp /opt/volumekeys/volumemute2 /opt/volumekeys/volumemute
file:///storage1/Multimedia/volumekeys/volumemute1reset
Code:
#!/bin/sh
cp /opt/volumekeys/volumemute2 /opt/volumekeys/volumemute
file:///storage1/Multimedia/volumekeys/volumemute2
Code:
#!/bin/sh
# copy of volumemute2
# This commands saves all current levels to ~/aumixrc
aumix -S
# This command turns master volume to off to 0 percent
aumix -v0
# This command copys the file volumemute1 to volumemute to be ready for the next press
cp /opt/volumekeys/volumemute1 /opt/volumekeys/volumemute
file:///storage1/Multimedia/volumekeys/volumeup
Code:
#!/bin/sh
aumix -v +5 -S
file:///storage1/Multimedia/volumekeys/volumeup1
Code:
#!/bin/sh
aumix -v +1 -S

List of keycodes I have found, but keycode numbers can vary.
keycode 122 = XF86Search
keycode 130 = XF86HomePage
keycode 144 = XF86AudioPrev
keycode 147 = XF86Word
keycode 148 = XF86Excel
keycode 153 = XF86AudioNext
keycode 160 = XF86AudioMute
keycode 161 = XF86Calculator
keycode 162 = XF86AudioPlay
keycode 163 = XF86ScrollClick
keycode 164 = XF86AudioStop
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 178 = XF86HomePage
keycode 178 = XF86WWW
keycode 223 = XF86Standby
keycode 229 = XF86Search
keycode 230 = XF86Start
keycode 231 = XF86Refresh
keycode 239 = XF86Mail

keycode 222 = XF86PowerOff
keycode 223 = XF86Sleep
keycode 230 = XF86Favorites
keycode 231 = XF86Refresh
keycode 232 = XF86Stop
keycode 236 = XF86Mail

keycode 234 = XF86Prev_VMode
keycode 233 = XF86Next_VMode
keycode 223 = XF86Sleep
keycode 229 = XF86Search
keycode 230 = XF86Favorites
keycode 231 = XF86Refresh
keycode 232 = XF86Stop
keycode 233 = XF86Forward
keycode 234 = XF86Back
keycode 235 = XF86MyComputer
keycode 236 = XF86Mail
keycode 237 = XF86AudioMedia

Brian1

Last edited by Brian1; 08-28-2005 at 08:52 PM.
 
Old 08-30-2005, 06:59 PM   #6
Matty-J
Member
 
Registered: Jun 2004
Distribution: SuSE 9.3, Debian Sarge
Posts: 65

Rep: Reputation: 15
Quote:
Originally posted by flower.Hercules
Run xev in the console and push the keys, grab the keycode from the output.

Take that keycode (for example keycode 223) and make this file: ~/.xmodmap

Edit that file to look something like this:

keycode 223 = F13


Then, check your specific Window Manager for these details, bind that F13 key to a command. Activate that modmap by typing `xmodmap ~/.xmodmap` in your terminal.

If you would like scripts to increase, decrease, and mute your volume, let me know and I will paste them here for you.

Hi,

I've got SuSE 9.3 installed on my Toshiba Satellite laptop which has keys that should launch programs and play/stop/next for music. however, when i run xev, none of these keys produce a code. Am I screwed for using theses keys, or is there something else I can try?

Any help would be greatly appreciated!!!

Thanks,
Matt
 
Old 08-30-2005, 07:06 PM   #7
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
Do you get a keycode with `showkey`...if not, do you get a response when running `showkey -s` ?
 
Old 08-30-2005, 07:19 PM   #8
Matty-J
Member
 
Registered: Jun 2004
Distribution: SuSE 9.3, Debian Sarge
Posts: 65

Rep: Reputation: 15
Hi,

I don't get anything when i press the extra keys with showkey and showkey -s...

I don't know if it'll help, but I'm also using gnome

Thanks,
matt
 
Old 08-30-2005, 07:27 PM   #9
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
Did you try running that outside of X? As showkey reports:

Quote:
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console]
Control + Alt + F1 to get into the terminal under X and type:

killall -9 gdm
killall -9 X

as root to kill gdm and then the X server to try those outside of X, then type gdm and then start X as your normal user to restart your rig (assuming you are using the gnome display manager).
 
Old 08-30-2005, 07:31 PM   #10
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
The theory behind key mapping is that a scancode generated by the device is mapped to a keycode in X. Some devices produce a scancode that the kernel does not recognize, therefore reporting nothing to you with xev. Although, I didn't think it would also return nothing to you with showkey, too.

If you can get the scancode, then with setkeycodes you can set a scancode to a defined keycode and then map that keycode. As the manual states: setkeycodes e06f 112 will set the scancode e06f (which is in hexidecimal) to the keycode 112.
 
Old 08-30-2005, 09:10 PM   #11
Matty-J
Member
 
Registered: Jun 2004
Distribution: SuSE 9.3, Debian Sarge
Posts: 65

Rep: Reputation: 15
Hi

Thanks for your replies. The showkey command didn't produce any results outside of X either. Also, I've been having a hell of a time finding the scancodes for the laptop... Does anybody know a good website that'll help me with this?

I also know that the keys actually work as they worked by default with Windows XP.

Thanks again,
Matt
 
Old 08-30-2005, 09:49 PM   #12
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
`showkey -s` === show scancodes :/
 
Old 08-31-2005, 09:04 AM   #13
Matty-J
Member
 
Registered: Jun 2004
Distribution: SuSE 9.3, Debian Sarge
Posts: 65

Rep: Reputation: 15
Well that sucks. Would there be drivers or something that would help?

Matt
 
Old 08-31-2005, 08:16 PM   #14
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
This might be of some help but haven't seen any advance in it for the last 4-5 months.
http://keytouch.sourceforge.net/
I would contact the developer and see what they have available.

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 Off
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 10:43 PM
mapping extra function keys in Gnome 2.2 evano Slackware 1 09-08-2005 06:17 PM
mapping custom keys TomalakBORG Linux - General 8 04-24-2005 04:27 PM
mapping the keyboard scroll whell to emulate + & - keys micker Linux - Software 2 01-25-2005 08:15 AM
mapping keyboard keys fedetxf Linux - Newbie 1 03-23-2004 09:49 PM


All times are GMT -5. The time now is 11:37 AM.

Main Menu
Advertisement
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