Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Howto: remapping buttons on Logitech MX Ergo (and other devices)

Help for Current Versions of MX
Post Reply
Message
Author
User avatar
Eadwine Rose
Forum Veteran
Forum Veteran
Posts: 6102
Joined: Wed Jul 12, 2006 2:10 am

Howto: remapping buttons on Logitech MX Ergo (and other devices)

#1 Post by Eadwine Rose » Fri Aug 17, 2018 5:14 am

Yay!! I managed to remap the two small buttons next to the left mouse button that were for Page back and Page forward in the browser.

I use gestures with an extension to do that back and forward in a browser by keeping the right button pressed and then moving the pointer either left or right. I found that I was doing that with this trackball as well, so... those two buttons were sitting there basically useless.

There HAD to be a way to remap them, here is how I did it. There are probably other ways, but this is the one that worked for me ;)



First install xbindkeys and xautomation

After installing xbindkeys, you'll need to generate a configuration file. The easiest way to do this is by running:

Code: Select all

xbindkeys --defaults > /home/username/.xbindkeysrc
I made a backup of that original file, just in case I might ever need it.
If you already HAVE an xbindkeysrc file you can add to that one. Just make sure when stopping and restarting you use the right path.


Now we need to check the numbers for those two buttons.

Open a terminal and enter:

Code: Select all

xev
A new window will pop up, move the mouse in there and press the buttons. An output will appear in the terminal. As you can see in my case they are numbered 8 and 9:

Code: Select all

ButtonPress event, serial 37, synthetic NO, window 0x7e00001,
    root 0x290, subw 0x0, time 9863287, (174,13), root:(1045,448),
    state 0x0, button 9, same_screen YES

ButtonRelease event, serial 37, synthetic NO, window 0x7e00001,
    root 0x290, subw 0x0, time 9863423, (174,13), root:(1045,448),
    state 0x0, button 9, same_screen YES

ButtonPress event, serial 37, synthetic NO, window 0x7e00001,
    root 0x290, subw 0x0, time 9864137, (174,13), root:(1045,448),
    state 0x0, button 8, same_screen YES

ButtonRelease event, serial 37, synthetic NO, window 0x7e00001,
    root 0x290, subw 0x0, time 9864241, (174,13), root:(1045,448),
    state 0x0, button 8, same_screen YES

Now open the hidden .xbindkeysrc in your /home/username folder and add the following:

Code: Select all

## Change click buttons on MX Ergo
#bottom button
"xte 'keydown Page_Up'"
   b:8
#bottom button release
"xte 'keyup Page_Up'"
   b:8 + release
#top button
"xte 'keydown Page_Down'"
   b:9
#top button release
"xte 'keyup Page_Down'"
   b:9 + release
Yes that seems backwards but the top button is easier to reach for me and I need the page down to be under that one ;) Also the keydown keyup bits ensure that when you press the page down button it will go down once, and when you hold the button it will continue to generate page downs until you release it.



Save the file, and then we need to kill all running xbindkeys:

Code: Select all

killall xbindkeys
And restart xbindkeys with your just adjusted configuration file:

Code: Select all

xbindkeys -f ~/.xbindkeysrc


No need to restart the computer, the effect is immediate.


To autostart this on login see the two methods mentioned in the posts below and pick your favorite :)



Sources used:
https://www.linux.com/news/start-programs-pro-xbindkeys
https://askubuntu.com/questions/624756/ ... se-buttons
https://superuser.com/questions/883782/ ... on/1174359
MX-17.1_x64 Horizon 14-3-2018 * 4.15.0-1-amd64 ext4 Xfce 4.12.3 * AMD Asus M4A785TD-V EVO AM3 * ASUS GF GT640-1GD5-L NVIDIA 384.130 * AMD Proc. Athl II X4 635, sAM3 * HDA ATI SB VT1708S An * 2x4Gb DDR3 1600 Kingst * 22" Samsung SyncM P2250 * HP F2280

User avatar
male
Forum Regular
Forum Regular
Posts: 295
Joined: Thu Jan 23, 2014 8:38 am

Re: Howto: remapping buttons on Logitech MX Ergo (and other devices)

#2 Post by male » Fri Aug 17, 2018 6:20 am

create an autostart-script in your /home (all applications can be included)
autostart-xfce.sh(mine already exists)

Code: Select all

#!/bin/bash
xmodmap ~/.Xmodmap
sleep 1 &&
xbindkeys -f ~/.xbindkeysrc
sleep 10 &&
conky -c ~/eadwine/.conkyrc10 &
then you need a "desktop configuration file" in the hidden directory
/home/eadwine/.config/autostart
XFCE_Autostart.desktop

Code: Select all

[Desktop Entry]
Name=XFCE Autostart
Comment=Automatically start listed applications when XFCE starts
Exec=/home/male/autostart-xfce.sh
Terminal=false
Type=Application
Categories=Configuration
which calls the script above.

I hope I haven't forgotten anything... ;)
Last edited by male on Fri Aug 17, 2018 9:27 am, edited 1 time in total.
Male is the capital of the Maldives and its wonderful people.

User avatar
Eadwine Rose
Forum Veteran
Forum Veteran
Posts: 6102
Joined: Wed Jul 12, 2006 2:10 am

Re: Howto: remapping buttons on Logitech MX Ergo (and other devices)

#3 Post by Eadwine Rose » Fri Aug 17, 2018 6:25 am

Aha... thanks for the hint!

Sorry I am not following your instruction to the letter here, but putting

Code: Select all

xbindkeys -f /home/username/.xbindkeysrc
into the session and startup section works.

No need for scripts and such.. I am a KISS person ;)
MX-17.1_x64 Horizon 14-3-2018 * 4.15.0-1-amd64 ext4 Xfce 4.12.3 * AMD Asus M4A785TD-V EVO AM3 * ASUS GF GT640-1GD5-L NVIDIA 384.130 * AMD Proc. Athl II X4 635, sAM3 * HDA ATI SB VT1708S An * 2x4Gb DDR3 1600 Kingst * 22" Samsung SyncM P2250 * HP F2280

User avatar
male
Forum Regular
Forum Regular
Posts: 295
Joined: Thu Jan 23, 2014 8:38 am

Re: Howto: remapping buttons on Logitech MX Ergo (and other devices)

#4 Post by male » Fri Aug 17, 2018 9:32 am

Eadwine Rose wrote:No need for scripts and such.. I am a KISS person ;)
you are the master of your computer :happy:
Male is the capital of the Maldives and its wonderful people.

truongtfg
Forum Novice
Forum  Novice
Posts: 15
Joined: Sun Jul 15, 2018 9:22 am

Re: Howto: remapping buttons on Logitech MX Ergo (and other devices)

#5 Post by truongtfg » Fri Aug 17, 2018 10:53 am

I think it is easier to use xinput. You can find the guide to use xinput here: https://askubuntu.com/questions/492744/ ... at-startup.

In my case, I use it in combination with easystroke app as I want to use the mouse forward button to scroll up and down (minus the pasting of middle button).

User avatar
Eadwine Rose
Forum Veteran
Forum Veteran
Posts: 6102
Joined: Wed Jul 12, 2006 2:10 am

Re: Howto: remapping buttons on Logitech MX Ergo (and other devices)

#6 Post by Eadwine Rose » Fri Aug 17, 2018 12:30 pm

True.. I forgot about xinput. I started out using that to see what numbers the buttons are.

As said: there are more ways than one ;)
MX-17.1_x64 Horizon 14-3-2018 * 4.15.0-1-amd64 ext4 Xfce 4.12.3 * AMD Asus M4A785TD-V EVO AM3 * ASUS GF GT640-1GD5-L NVIDIA 384.130 * AMD Proc. Athl II X4 635, sAM3 * HDA ATI SB VT1708S An * 2x4Gb DDR3 1600 Kingst * 22" Samsung SyncM P2250 * HP F2280

Post Reply

Return to “MX Help”