Saturday, May 30, 2015

Microsoft Natural Keyboard 4000 in Linux Fedora 21 LXDE

Microsoft Natural 4000 is great keyboard, but on Linux, well at least in my case multimedia keys didn't work out of the box. I had to figure out how to make them work.

First, I wanted to use custom shortcuts for buttons like HomePage, Search, Email and those numbered 1-5.

To find out does X detects your keypresses in console start xev.

xev | egrep -o "keycode.*\)"

While program is running press keys you would like to map. Result should be something like this:

keycode 195 (keysym 0x1008ff48, XF86Launch8)
keycode 195 (keysym 0x1008ff48, XF86Launch8)

Keep in mind that xev detects key press and key release as separate events. What we need from here is XF86Launch8.

Open file ~/.config/openbox/lxde-rc.xml in your favorite text editor and find line with </keyboard> in it. You need to write your keybindings between <keyboard>  and </keyboard>. I like to add mine just above </keyboard> because it's easier for me to find it later.
Now insert actual keybinding. This particular key I want to use for starting teamviewer.

<keybind key="XF86Launch8">
    <action name="Execute">
      <command>teamviewer</command>
    </action>
  </keybind> 

 Save file and in console execute openbox --reconfigure

For more info check out http://wiki.lxde.org/en/LXDE:Questions#Modify_mouse.2Fkeyboard_bindings

Zoom slider


Problem with zoom slider is that xev doesn't detect anything when you move it. After reading many posts I found what works for me.
Create file /etc/udev/hwdb.d/70-keyboard.hwdb
You will need to create folder hwdb.d because it doesn't exist.

with this content

# Microsoft Natural Ergonomic Keyboard 4000
keyboard:usb:v045Ep00DB*
 KEYBOARD_KEY_c022d=zoomin
 KEYBOARD_KEY_c022e=zoomout

Instead of "zoomin" or "zoomout" you could give keys different function like pageup and pagedown if you want to use this key for scrolling through page. Or even up and down to scroll line by line.
Save file and run sudo udevadm hwdb --update after that you might need to unplug and plugin your keyboard again or if that doesn't help, reboot.

No comments:

Post a Comment