[0x1][Hardware] - Configure & Use Logitech MX Master 3 Wireless Mouse on Linux

Logitech MX Master 3 Wireless Mouse

Goal

Fully configure Logitech MX Master 3 Wireless Mouse on Linux using logiops, an unofficial driver for Logitech mice and keyboard that makes it possible to acquire everything this mouse has to offer.

Problem

The official software that fully configures the mouse (Logitech Options) cannot run on Linux.

Solution

The first thing to do is to read The Sacred Texts here

Arch Wiki - The Sacred Texts


Installation

With logiops, it is possible to acquire everything this mouse has to offer:

  • Easy programmable buttons.
  • DPI selection.
  • Smartshift (hyperfast and click-to-click wheel mode).
  • HiresScroll.
  • Gestures.

To install logiops on Arch, issue the below command

yay -S logiops-git

For other Linux distributions, see the Dependencies and Building sections.

Configuration

The first thing is to get the device’s name

sudo logid -v

[DEBUG] Unsupported device /dev/hidraw0 ignored
[DEBUG] Unsupported device /dev/hidraw1 ignored
[DEBUG] Unsupported device /dev/hidraw4 ignored
[DEBUG] Unsupported device /dev/hidraw3 ignored
[DEBUG] Unsupported device /dev/hidraw2 ignored
[INFO] Detected receiver at /dev/hidraw5
[INFO] Device found: Wireless Mouse MX Master 3 on /dev/hidraw5:1
[WARN] Line 51: action is a required field, skipping.
[DEBUG] /dev/hidraw5: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
[WARN] Error adding device /dev/hidraw6: std::exception

Press CTRL+C to exit.

As you can clearly see, the name of the device is Wireless Mouse MX Master 3, keep that in mind or note it down for later.

Now, we have to edit its configuration file:

sudo -i
cat << EOF > /etc/logid.cfg
devices: ({
	# Put the name of the device here
	name: "Wireless Mouse MX Master 3";
	dpi: 2800;
	smartshift: {
		on: true;
		# 1-255 integer
		threshold: 200;
		default_threshold: 200;
	};
	hiresscroll: {
		hires: true;
		invert: false;
		target: false;
		up: {
			mode: "Axis";
			axis: "REL_WHEEL_HI_RES";
			axis_multiplier: 6;
		},
		down: {
			mode: "Axis";
			axis: "REL_WHEEL_HI_RES";
			axis_multiplier: -6;
		}
	};
	buttons: ({
		# Gesture Button
		cid: 0xc3;
		action = {
			type: "Gestures";
			gestures: ({
				# Toggle fullscreen of current window - This needs custom keybinding (current: XFCEWM)
				direction: "Up";
				mode: "OnFewPixels";
				pixels: 350;
				action = {
					type: "Keypress";
					keys: ["KEY_LEFTALT", "KEY_F11"];
				};
			}, {
				# Capture selective screenshot - This needs custom keybinding (current: XFCE keyboard shortcut)
				direction: "Down";
				mode: "OnFewPixels";
				pixels: 500;
				action = {
					type: "Keypress";
					keys: ["KEY_LEFTCTRL", "KEY_LEFTMETA", "KEY_PRINT"];
				};
			}, {
				# Scroll tabs - left
				direction: "Left";
				mode: "OnFewPixels";
				pixels: 250;
				action = {
					type: "Keypress";
					keys: ["KEY_LEFTCTRL", "KEY_PAGEDOWN"];
				};
			}, {
				# Scroll tabs - right
				direction: "Right";
				mode: "OnFewPixels";
				pixels: 250;
				action = {
					type: "Keypress";
					keys: ["KEY_LEFTCTRL", "KEY_PAGEUP"];
				}
			}, {
				# This button is being used as toggle mute (system-wide) - This needs custom keybinding (current: XFCE keyboard shortcut)
				direction: "None";
				mode: "OnRelease";
				action = {
					type: "Keypress";
					keys: ["KEY_LEFTMETA", "KEY_END"];
				}
			});
		};
	}, {
		# Toggle SmartShift
		cid: 0xc4;
		action = {
			type = "ToggleSmartshift";
		};
	}, {
		# Back Button (has 0x54 too)
		cid: 0x53;
		action = {
			type :  "Keypress";
			keys: ["KEY_BACK"];
		};
	}, {
		# Forward Button (has 0x57 too)
		cid: 0x56;
		action = {
			type :  "Keypress";
			keys: ["KEY_FORWARD"];
		};
	});
}, {
	# Another device to configure
	name: "Other Logitech USB Receiver: MUST BE CONFIGURED FIRST";
});
EOF

Also, here are my keyboard shortcuts (XFCE):

Keyboard Shortcuts

This is my configuration based on my needs (without Logitech Flow). You can inspect the input-event-codes of Linux here to adjust the keys and read the Wiki of logiops for syntax and CIDs here.

Everytime you edit the configuration file, it is highly recommended to run the logid command withthe debug option, like this:

sudo logid -v -c /etc/logid.cfg

[DEBUG] Unsupported device /dev/hidraw0 ignored
[DEBUG] Unsupported device /dev/hidraw1 ignored
[DEBUG] Unsupported device /dev/hidraw4 ignored
[DEBUG] Unsupported device /dev/hidraw3 ignored
[DEBUG] Unsupported device /dev/hidraw2 ignored
[INFO] Detected receiver at /dev/hidraw5
[INFO] Device found: Wireless Mouse MX Master 3 on /dev/hidraw5:1
[WARN] Line 56: action is a required field, skipping.
[DEBUG] /dev/hidraw5: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
[WARN] Error adding device /dev/hidraw6: std::exception

and exit with CTRL+C.

Finally, start the daemon and enable autostart:

sudo systemctl start logid
sudo systemctl enable logid

TODO

  • Custom horizontal scroll to use KEY_UP and KEY_DOWN instead, with xkeybind bash script.