Skip to content

Instantly share code, notes, and snippets.

@denalena
Forked from pedrovhb/set_ergo_scroll.py
Created April 4, 2023 14:57
Show Gist options
  • Save denalena/80b5d0f50840da383c971d2cf89d181e to your computer and use it in GitHub Desktop.
Save denalena/80b5d0f50840da383c971d2cf89d181e to your computer and use it in GitHub Desktop.
This makes it so that as long as that button is being held, moving the cursors scrolls instead.
#! /usr/bin/env python
import re
import subprocess
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:
rc = subprocess.run(
[
"xinput",
"set-prop",
ergo_id,
"libinput Scroll Method Enabled",
"0,",
"0,",
"1",
]
).rc
assert rc == 0
rc = subprocess.run(
[
"xinput",
"set-prop",
ergo_id,
"libinput Button Scrolling Button",
"8",
]
)
assert rc == 0
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