Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johnathanmay/77e8cfefda6744dca39cb1311bdf741a to your computer and use it in GitHub Desktop.
Save johnathanmay/77e8cfefda6744dca39cb1311bdf741a to your computer and use it in GitHub Desktop.
How to install and configure PixlOne's logid to program Logitech MX Master 3 buttons on Linux.

Logitech MX Master 3 Extras for Linux With logiops

The Logitech Options program isn't available for Linux, but by a nice guy on GitHub (PixlOne) created an open source project that lets you obtain some of that functionality. It's called logiops. It works in conjunction with the Solaar project as well, which I find especially handy since that shows your available battery life in the system tray and lets you pair/unpair devices with the Logitech Unifying Receiver.

Here are some additional pages with info that I used to generate this documentation:

Installation

Installation instructions for different distributions are available from the developer, but here are the commands for an Ubuntu workstation (I've verified it works with 20.04, 21.10, and 22.04):

sudo apt install -y cmake libevdev-dev libudev-dev libconfig++-dev
git clone https://github.com/PixlOne/logiops
cd logiops
mkdir build
cd build
cmake ..
make
sudo make install
sudo touch /etc/logid.cfg
sudo systemctl enable --now logid

My /etc/logid.cfg File

This setup is pretty basic. Although gestures are supported and an example config with that is provided within the GitHub project, the only functionality I wanted to add that I couldn't get from Solaar, was a way to launch the GNOME Activities window (i.e. press the Super/Meta/Logo key) with the mouse. Here's how:

echo 'devices: (
{
    name: "Wireless Mouse MX Master 3";
    smartshift:
    {
        on: true;
        threshold: 10;
    };
    hiresscroll:
    {
        hires: true;
        invert: false;
        target: false;
    };
    dpi: 1000;

    buttons: (
        {
            cid: 0x52;
            action =
            {
                type: "Keypress";
                keys: ["KEY_LEFTMETA"];
            };
        }
    );
}
);' | sudo tee /etc/logid.cfg 
sudo systemctl restart logid

Programmable Mouse Buttons

Note that I chose to configure the scroll wheel button, but any of the following buttons are available for you to play with:

  • 0x52 - scroll wheel button
  • 0x53 - back button
  • 0x56 - forward button
  • 0xc3 - thumb button (default "Gesture" button with Logitech Options software)
  • 0xc4 - mode shift button (by default toggles between ratchet and free-spin wheel modes)

Extra Notes

Example output running sudo logid -v after creating /etc/logid.cfg:

[ERROR] I/O Error while reading /etc/logid.cfg: FileIOException
[DEBUG] Unsupported device /dev/hidraw1 ignored
[DEBUG] Unsupported device /dev/hidraw2 ignored
[DEBUG] Unsupported device /dev/hidraw0 ignored
[WARN] Error adding device /dev/hidraw4: std::exception
[INFO] Detected receiver at /dev/hidraw3
[INFO] Device Wireless Mouse MX Master 3 not configured, using default config.
[INFO] Device found: Wireless Mouse MX Master 3 on /dev/hidraw3:1
[DEBUG] /dev/hidraw3:1 remappable buttons:
[DEBUG] CID  | reprog? | fn key? | mouse key? | gesture support?
[DEBUG] 0x50 |         |         | YES        | 
[DEBUG] 0x51 |         |         | YES        | 
[DEBUG] 0x52 | YES     |         | YES        | YES
[DEBUG] 0x53 | YES     |         | YES        | YES
[DEBUG] 0x56 | YES     |         | YES        | YES
[DEBUG] 0xc3 | YES     |         | YES        | YES
[DEBUG] 0xc4 | YES     |         | YES        | YES
[DEBUG] 0xd7 | YES     |         |            | YES
[DEBUG] Thumb wheel detected (0x2150), capabilities:
[DEBUG] timestamp | touch | proximity | single tap
[DEBUG] YES       | YES   | YES       | YES       
[DEBUG] Thumb wheel resolution: native (18), diverted (120)

Solaar Rules

In Ubuntu 22.04, Solaar adds the ability to create your own rules for modifying the mouse button behavior, but after spending about 15 minutes reading through the official documentation, and trying to create user rules, I was unable to figure out how to replicate the Logitech Options behavior I was expecting - namely assigning commands to specific buttons. Perhaps it was because "rule processing only fully works under X11" and Ubuntu uses Wayland?

Either way, the process I originally documented for Ubuntu 20.04 worked flawlessly for me with Ubuntu 22.04. By specifying the button ID and the action in the /etc/logid.cfg file, it just works. The config described below is pretty basic, so I recommend checking out the logiops wiki Configuration page for more advanced options with actions and gestures.

@Huholoman
Copy link

Why does ot say "Device Wireless Mouse MX Master 3 not configured, using default config."?

@johnathanmay
Copy link
Author

I'm not sure, but I expect that's just what it says when it initially detects the device. The main reason I added those extra notes was to show the various mouse buttons that can be configured based on their "CID" number.

@Huholoman
Copy link

Ive bought the mx master 3 today and im trying to change some settings and it writes device not configured... 🙈 ok, ill try to change something and see if mouse behaviour is changed.

@ipeacocks
Copy link

ipeacocks commented Jul 11, 2022

In 22.04 mouse buttons become default after laptop suspend. But logid service works.

@fadonoso
Copy link

Thanks!! , Is it possible to add a sequence of commands to a mouse button as for example: Ctrl + Ctrl + 1 ?

@johnathanmay
Copy link
Author

I don't see a way to do that looking at the KeypressAction.cpp source code. As I understand it, it's just a list of keys that get pressed - so you can press more than one, by simply adding the combined keys in the list, separating them by commas, but they are all released at the same time. Any combination you use for keyboard shorcuts in Ubuntu can assigned here.

@dvileta
Copy link

dvileta commented Aug 23, 2023

@johnathanmay You should recheck/trim the first line and last 2 lines of the /etc/logid.cfg that you posted - looks like its from a shell script.

@garevans
Copy link

garevans commented Jun 9, 2024

On the desktop version of Ubuntu 24.04 LTS I also needed the following dependencies:
sudo apt-get update && sudo apt-get install build-essential libglib2.0-dev

I'm trying to map the back / forward buttons to volume up / down - does anybody know where the list of Keypress commands is?
(e.g. KEY_LEFTMETA)

Found the list for those who stumble upon this comment years from now:
https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h

KEY_VOLUMEDOWN
KEY_VOLUMEUP

@Gusfit1
Copy link

Gusfit1 commented Oct 24, 2024

Here's my base config, using the side buttons for volume control.

For anyone else wondering, this is meant to be pasted directly into terminal. Hit enter and it will overwrite logid.cfg and restart the service, putting your changes into effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment