Difference between revisions of "Use Additional Mouse Buttons"

From LinuxMCE
Jump to: navigation, search
m (fixed 2 type-os)
m (How it works)
Line 1: Line 1:
{| align="right"
+
{| align="right"
 
   | __TOC__
 
   | __TOC__
 
   |}
 
   |}
Line 30: Line 30:
 
== How it works ==
 
== How it works ==
 
We use '''xautomation (xte)''' to simulate the key-presses:
 
We use '''xautomation (xte)''' to simulate the key-presses:
If you want to send a keypress of F6 to the X-Server, the command "xte 'key F8'" will do the trick.
+
If you want to send a keypress of F8 to the X-Server, the command "xte 'key F8'" will do the trick.
 
If you only want to send that the key was pressed, call "xte 'keydown F8".
 
If you only want to send that the key was pressed, call "xte 'keydown F8".
 
additionally you can event move the mouse or do clicks with it. For more information have a look at "man xte".
 
additionally you can event move the mouse or do clicks with it. For more information have a look at "man xte".

Revision as of 16:41, 13 February 2008

Abstract This is an article, explaining how to use additional mousebuttons as substitude to F6, F7, F8.

This way, LinuxMCE can be controlled with a (wireless) mouse only, without the need to have a keyboard nearby...


Prerequisits

First of all, we need the packets xautomation (which should be installed allready) and xbindkeys.

Before installing them, wen need to append "deb http://archive.ubuntu.com/ubuntu/ feisty universe" to /etc/apt/sources.list temporarely and resync the repository (see Editing_Text).

#get a console:
sudo nano -w /etc/apt/sources.list
#add the following:
deb http://archive.ubuntu.com/ubuntu/ feisty universe
#CTRL+X and Y to exit and save
#update the repository
sudo apt-get update
#Remember to remove the line afterwards and do an update again

Then we need to install those 2 packets:

#get a console:
sudo apt-get install xbindkeys
sudo apt-get install xautomation

How it works

We use xautomation (xte) to simulate the key-presses: If you want to send a keypress of F8 to the X-Server, the command "xte 'key F8'" will do the trick. If you only want to send that the key was pressed, call "xte 'keydown F8". additionally you can event move the mouse or do clicks with it. For more information have a look at "man xte".

To catch the keypresses on the mouse, we use xbindkeys. The syntax of the config-file is:

"xterm"
   control+shift + q

so within the "" is the command to call and below is the key to bind the command to. possible keys are control, shift, alt, ... and for mouse-buttons b:1, b:2, b:3, ...

Configuring it

Combining those two, we derive the following configfile, which i saved at /etc/xbindkeysrc:

#get a console
sudo nano -w /etc/xbindkeysrc
#Add the following
"xte 'keydown F6' &"
  b:8
"xte 'keyup F6' &"
  b:8+release

"xte 'keydown F7' &"
  b:2
"xte 'keyup F7' &"
  b:2+release

"xte 'keydown F8' &"
  b:9
"xte 'keyup F8' &"
  b:9+release
#Close it with CTRL+X and Save with Y

Then we still have to start xbindkeys within the X-Server... As I do not know LinuxMCE too well, I just looked for some good spot and /usr/pluto/bin/lmce_launch_manager.sh seemed to be one. Now it looks like this:

#get a console
sudo nano -w /usr/pluto/bin/lmce_launch_manager.sh
#add the line with xbindkeysrc
...
xbindkeys -f /etc/xbindkeysrc      #<--- the added stuff

KDE_DEBUG=1
LM_BINARY=/usr/pluto/bin/lmce_launch_manager
LM_EXIT_CODE=-1
...
#CTRL+X to exit and Y to save

Result

After a reboot, the mouse-buttons 8, 2 and 9 should act as F6, F7 and F9 even passing when a key is held pressed, which was the right setup for me. If you want something different, just change b:9 for b:6 for example.

If you don't know the numbers of your mousebuttons, start the "application" xev. Click into the small black box and look at the console for the output "ButtonPress event, .... button X".

Troubleshooting

In case you do not get all the buttons of your mouse, e.g. 8 and 9 report as being 1 and 2 (that was the case with my mouse), try replacing the following in /etc/X11/xorg.conf

Option          "Protocol"              "ImPS/2"

with

Option          "Protocol"              "ExplorerPS/2"