Saturday, September 12, 2020

Binding Mouse Buttons on Linux Mint Tricia

 Following describes how was the mouse buttons response and configured for

Tinytech GM-924 on Linux Mint 19.3 Tricia.


Initial response

A. Firefox web browser

Within the Firefox web browser, the left and right mouse buttons functioned as normal. The center scroll button caused the audio volume to increase or decrease. When scroll button was clicked, an X appeared.

At the left side were 2 buttons. Both only showed an X when clicked.

Hold down Left+Right button, the auto scroll appears. If this doesn't appear in Firefox web browser, you can set it up in Firefox menu.

Menu ->Preferences. Search for scroll.

Enable "Auto Scrolling", restart Firefox web browser.

Sometimes, there isn't any response to the mouse after I touched the USB connection. I have not found any reason for this. However, you can enable the mouse again by pressing the button above the scroll button.

B. Command prompt window

On the command line terminal window.

Left click on a text line, will highlight a word.

Left double click on a text line, will highlight the whole sentence.

Left+Right button click will paste the last highlight text. 

Right button will open the options windows.

Scroll button works the same as Left+Right button click.

Scroll front and back scrolls up and down the screen window.


How does Linux mint detect these buttons? 

Open command line terminal and run a simple test by clicking each of the button. 

 xev -event button

Here are the results I got;

  • Left button - Button 1, state 0x100
  • Right button - Button 3, state 0x400
  • Left+Right button - Button 2, state 0x200
  • Scroll button - Button 2, state 0x200
  • Scroll button push forwxbindkeys - Associate a combination of keys or mouse buttons with a shell commandard - Button 5, state 0x1000
  • Scroll button pull backwards - Button 4, state 0x800
  • Side forward button - Button 9, state 0x0
  • Side back button - Button 8, state 0x0

How to program the side forward and back buttons?

Install the package xbindkeys and xvkbd, from the description it says;

xbindkeys - xbindkeys is a program that allows you to launch shell commands with
 your keyboard or your mouse under the X Window System.
It links commands to keys or mouse buttons, using a configuration file.
It's independent of the window manager and can capture all keyboard keys

xvkbd - xvkbd is a virtual (graphical) keyboard program for X Window System
 which provides facility to enter characters onto other clients
 (software) by clicking on a keyboard displayed on the screen.  This
 may be used for systems without a hardware keyboard such as kiosk
 terminals or handheld devices.  This program also has facility to
 send characters specified as the command line option to another
 client.

I refer to syntax at http://xahlee.info/linux/linux_xvkbd_tutorial.html

The configuration here is per user. It means, the file must be configured for each user in the system.

  1. Edit the file ~/.xbindkeys 
  2. Restart xbindkeys service

pkill -f xbindkeys

xbindkeys

Here are 2 example of the file ~/.xbindkeys

Example 1: Launch xed and nemo

In order launch nemo file manager, with the side front button AND to lauch xed text editor with the side back button.

# bind side left forward button
"xed"
  m:0x0 + b:8
"nemo"
  m:0x0 + b:9

 

Example 2: Supertuxkart 

Use the numpad 4 is view from left and numpad 6 is view from right. This is for laptops that doesn't have the side full numeric keypad that is normally found on desktop keyboards.

Lets program the side front for numpad 4, side back button for numpad 6.

"xvkbd -text '\[KP_4]' "
  m:0x0 + b:8
"xvkbd -text '\[KP_6]' "
  m:0x0 + b:9


Blog Archive