LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   mapping non standard keyboard keys (http://www.linuxquestions.org/questions/linux-hardware-18/mapping-non-standard-keyboard-keys-356014/)

gravesb 08-22-2005 10:43 PM

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.

flower.Hercules 08-22-2005 10:56 PM

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.

gravesb 08-28-2005 06:53 PM

Please do.

flower.Hercules 08-28-2005 07:08 PM

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


Brian1 08-28-2005 07:42 PM

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

Matty-J 08-30-2005 05:59 PM

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

flower.Hercules 08-30-2005 06:06 PM

Do you get a keycode with `showkey`...if not, do you get a response when running `showkey -s` ?

Matty-J 08-30-2005 06:19 PM

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

flower.Hercules 08-30-2005 06:27 PM

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).

flower.Hercules 08-30-2005 06:31 PM

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.

Matty-J 08-30-2005 08:10 PM

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

flower.Hercules 08-30-2005 08:49 PM

`showkey -s` === show scancodes :/

Matty-J 08-31-2005 08:04 AM

Well that sucks. Would there be drivers or something that would help?

Matt

Brian1 08-31-2005 07:16 PM

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


All times are GMT -5. The time now is 03:34 PM.