Skip to content

Instantly share code, notes, and snippets.

@Djuuu
Created December 28, 2019 21:33
Show Gist options
  • Save Djuuu/0a576ec006ba23c24c9576d6a36baaed to your computer and use it in GitHub Desktop.
Save Djuuu/0a576ec006ba23c24c9576d6a36baaed to your computer and use it in GitHub Desktop.
Logitech MX Master 3 - horizontal scroll as buttons - sensitivity reduction on Linux (xbindkeys & external script)
## Scrollwheel left
"~/.xbindkeys/MX-Master-3-bindings.sh Scroll_L"
b:7 + release
## Scrollwheel right
"~/.xbindkeys/MX-Master-3-bindings.sh Scroll_R"
b:6 + release
#!/usr/bin/env bash
button=$1
# Horizontal scroll sensitivity reduction
hScrollModulo=3
hScrollIndexBuffer="/dev/shm/LogitechMXMaster3HScroll"
function temporizeHorizontalScroll {
local newDirection=$@;
# read buffer
local buffer=(`cat $hScrollIndexBuffer`)
local oldDirection=${buffer[0]}
local value=${buffer[1]}
if [ "$oldDirection" = "$newDirection" ]; then
# increment
((value++))
((value%=$hScrollModulo))
else
# reset on direction change
value=1
fi
# write buffer
echo "$newDirection $value" > $hScrollIndexBuffer || value=0
# temporize scroll
[ ${value} -ne 0 ] && exit;
}
case "$button" in
"Scroll_L")
temporizeHorizontalScroll "L"
xdotool key --clearmodifiers ctrl+shift+Tab; ;; # Previous tab
;;
"Scroll_R")
temporizeHorizontalScroll "R"
xdotool key --clearmodifiers ctrl+Tab; ;; # Next tab
;;
# ...
esac
@Sebelino
Copy link

Sebelino commented May 31, 2022

@jmarcet By TOP, do you mean the Smart Shift button? One way is to create a couple of new rules in Solaar: one for pressing the button, one for releasing it. If pressed, a 1 is written to a different file below /dev/shm/. If released, a 0 is written. Then adjust the script in this gist so it reads this file and executes xdotool conditionally based on the file contents.

image

@jmarcet
Copy link

jmarcet commented May 31, 2022

@Sebelino Thanks, I'll try it out.

@jmarcet
Copy link

jmarcet commented Jun 3, 2022

@Sebelino At the moment I've settled with this and it's working beautifully:

image

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