Skip to content

Instantly share code, notes, and snippets.

@Enteleform
Forked from pedrovhb/set_ergo_scroll.py
Last active September 28, 2024 03:28
Show Gist options
  • Save Enteleform/b6dcc3c7c7b9ede1fb9db7c31818cc48 to your computer and use it in GitHub Desktop.
Save Enteleform/b6dcc3c7c7b9ede1fb9db7c31818cc48 to your computer and use it in GitHub Desktop.
Logitech MX Ergo - Trackball Scroll Mode

Original Post

Oh boy, I found/invented a tweak that I can't live without anymore. I use an MX Ergo trackball, not sure how it'd fare on a mouse, but here are the magic runes:

xinput set-prop <mouse device id> "libinput Scroll Method Enabled" 0 0 1
xinput set-prop <mouse device id> "libinput Button Scrolling Button" 8

Where you'd change 8 to a chosen mouse button and the mouse device id to its appropriate value from xinput list.

What this does is make it so that as long as that button is being held, moving the cursors scrolls instead. It's hard to describe how much better of n experience it is vs. using the scroll wheel. It's much faster, much more precise, and less finger-tiring.

Here's a gist of the Python script I use to set it up - https://gist.github.com/pedrovhb/41e9d5b7b7b5c13fe2c94aa4cee1193a


User Comment

wow that's neat! I use and love the same device and while it feels a bit odd at first it also feels better than using the scroll wheel. btw in case anyone wants to try a different button (8 is "Page back") you can use `xinput test ` to listen to events and see which number each button is. Good news: it seems like the Back button still works when using this. Thanks!

edit:

Putting this in ~/.xsessionrc seems to work fine for me on Ubuntu:

xinput set-prop "pointer:Logitech MX Ergo" "libinput Button Scrolling Button" 8
xinput set-prop "pointer:Logitech MX Ergo" "libinput Scroll Method Enabled" 0 0 1
#! /usr/bin/env python
# This makes it so that as long as that button is being held, moving the cursors scrolls instead.
import re
import subprocess
import textwrap
RE_LOGITECH_ID = rb"Logitech MX Ergo[\s\-\w]+id=(\d+).*pointer"
def set_ergo_scroll() -> None:
"""Set button scrolling behavior for MX Ergo."""
print("Setting ergo scroll...")
inputs = subprocess.run(["xinput", "list"], capture_output=True).stdout
ergo_ids = re.findall(RE_LOGITECH_ID, inputs)
for ergo_id in ergo_ids:
commands = (
[
"xinput",
"set-prop",
ergo_id,
"libinput Scroll Method Enabled",
"0,",
"0,",
"1",
],
["xinput", "set-prop", ergo_id, "libinput Button Scrolling Button", "8"],
)
for cmd in commands:
proc = subprocess.run(cmd, capture_output=True)
if proc.returncode != 0:
print(f"Error calling xinput.\n")
print(f"stdout:")
print(textwrap.indent(proc.stdout.decode(), " "))
print(f"stderr:")
print(textwrap.indent(proc.stderr.decode(), " "))
exit()
print("Ergo scroll set.")
if __name__ == "__main__":
set_ergo_scroll()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment