Author Topic: Howto: Make additional mouse-buttons behave as F6, F7, F8  (Read 1758 times)

chewi

  • Veteran
  • ***
  • Posts: 69
    • View Profile
Howto: Make additional mouse-buttons behave as F6, F7, F8
« on: September 19, 2007, 10:59:46 am »
As i'm currently using only a wireless mouse to work with my LMCE and I was annoyed by using the keyboard for F6,F7,F8, I tried to figure out a way to have the additional mouse-buttons act as those keys...
If there is a simpler way, please reply and let me know...
If you have the same problem, enjoy...

First of all, we need the packets xautomation (which should be installed allready) and xbindkeys (which we can install by sudo apt-get install xbindkeys; you might have to append "deb http://archive.ubuntu.com/ubuntu/ feisty universe" to /etc/apt/sources.list temporarely, if i recall it correctly).

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

combining those two, we derive the following configfile, which i saved at /etc/xbindkeysrc:
Code: [Select]
"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

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:
Code: [Select]
...
xbindkeys -f /etc/xbindkeys      <--- the added stuff

KDE_DEBUG=1
LM_BINARY=/usr/pluto/bin/lmce_launch_manager
LM_EXIT_CODE=-1
...

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

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
Code: [Select]
Option          "Protocol"              "ImPS/2"
with
Option          "Protocol"              "ExplorerPS/2"

Hope that helps some of you to save some time...

Cheers... Chewi

golgoj4

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1074
  • hrumpf!
    • View Profile
    • La Smarthomes - SoCal smarthome site
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #1 on: October 24, 2007, 09:16:59 am »
tried this last night, but i seemed to have some issues with the dependencies.  :-\ Granted im new linux as a whole, but im not that thick headed...

Maybe im adding the wrong information into the sources.list?

day two...i think i need to go rtfm. install, compile..all new to me  :(
« Last Edit: October 25, 2007, 02:04:37 am by golgoj4 »
Those people who tell you not to take chances, they are all missing what life's all about.

Wiki Hardware Page http://wiki.linuxmce.org/index.php/User:Langstonius

chewi

  • Veteran
  • ***
  • Posts: 69
    • View Profile
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #2 on: October 26, 2007, 10:54:33 am »
you don't have to compile anything...

try editing the file /etc/apt/sources.list from the commandline with e.g. "sudo nano -w /etc/apt/sources.list"
then type "sudo apt-get update". this will actually add the additional repositories...

and with "sudo apt-get install <thepacket>" you can actually install e.g. xautomation or xbindkeys...

chriss

  • Veteran
  • ***
  • Posts: 140
    • View Profile
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #3 on: October 26, 2007, 01:20:50 pm »
Chewi,

what do you think about transfering your howto into the wiki? Maybe we should have a category for howtos then...

Cheers,
Chriss

chewi

  • Veteran
  • ***
  • Posts: 69
    • View Profile
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #4 on: October 26, 2007, 08:40:40 pm »
Sure, I just didn't want to do so, until someone would try it out and give me feedback...
So if someone can confirm, that this howto works, I'll happily post it to the wiki...

golgoj4

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1074
  • hrumpf!
    • View Profile
    • La Smarthomes - SoCal smarthome site
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #5 on: October 26, 2007, 09:04:50 pm »
Hey Chewi, thanks for the reply. I was actually going to add it to the wiki once I got it working. This is a really cool project and while im a relative noobie to linux as a whole, I figure I can at least help with organization and whatnot. Anyways, I have more time today so im planning to make another go.
Those people who tell you not to take chances, they are all missing what life's all about.

Wiki Hardware Page http://wiki.linuxmce.org/index.php/User:Langstonius

chewi

  • Veteran
  • ***
  • Posts: 69
    • View Profile
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #6 on: October 26, 2007, 10:32:17 pm »
Ok, and if it doesn't work, please let me know, so I can walk you through the whole thing...
Maybe by Live-Chat or anything... Just have to find a certain time considering the time-zones (Central-European here ;) )

golgoj4

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1074
  • hrumpf!
    • View Profile
    • La Smarthomes - SoCal smarthome site
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #7 on: October 27, 2007, 12:51:17 am »
Ok, so I got everything installed. Some observations

-Original sources.list was quite bare. Restored from Backup.list and it worked.
  *was able to get xbindkeys and xautomation via apt get

  *making the config was easy. copying it to the named directory was bit harder due to it being outside the home directory. same for 'lmce_launch_manager.sh' do you have an easier way to do that? I eventually figured out the shell commands to copy them from the home directory back to usr/pluto/bin and /etc/ respectively.

  *restarted, but no dice.

do i need xbindkeysconfig?

-langston

Those people who tell you not to take chances, they are all missing what life's all about.

Wiki Hardware Page http://wiki.linuxmce.org/index.php/User:Langstonius

golgoj4

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1074
  • hrumpf!
    • View Profile
    • La Smarthomes - SoCal smarthome site
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #8 on: October 27, 2007, 01:07:01 am »
Ok, so I got everything installed. Some observations

-Original sources.list was quite bare. Restored from Backup.list and it worked.
  *was able to get xbindkeys and xautomation via apt get

  *making the config was easy. copying it to the named directory was bit harder due to it being outside the home directory. same for 'lmce_launch_manager.sh' do you have an easier way to do that? I eventually figured out the shell commands to copy them from the home directory back to usr/pluto/bin and /etc/ respectively.

  *restarted, but no dice.

do i need xbindkeysconfig?

-langston



Solved - Small note in your howto. the file created in etc/ is xbindkeysrc and the file it looks for on startup is xbindkeys. Once i changed that, it was working and im configuring the mouse buttons now!

2 people is good enough for adding to the wiki I think, as long as we clarify for noobies like me the best method for editing files as root.
Those people who tell you not to take chances, they are all missing what life's all about.

Wiki Hardware Page http://wiki.linuxmce.org/index.php/User:Langstonius

chewi

  • Veteran
  • ***
  • Posts: 69
    • View Profile
Re: Howto: Make additional mouse-buttons behave as F6, F7, F8
« Reply #9 on: October 29, 2007, 11:21:48 am »
Ok, I posted it to http://wiki.linuxmce.org/index.php/Use_Additional_Mouse_Buttons

I didn't know a better name for it... ;)