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
@Djuuu
Copy link
Author

Djuuu commented Dec 28, 2019

See more advanced shortcut samples (with modifiers and application-specific) in my dotfiles:

@TheMoye
Copy link

TheMoye commented Jan 8, 2020

Hello Djuuu,

Très intéressant !
Question : sous Debian 10 / Cinnamon, la molette de la Master MX 3 passe en mode libre au moindre tour de molette.
Est-ce qu'il serait possible de régler la sensibilité du (ou désactiver) passage auto en mode libre ?

@Djuuu
Copy link
Author

Djuuu commented Jan 8, 2020

Dans la dernière version de Solaar, il y a un slider pour régler la sensibilité du "smart shift" des MX master.
Si tu ne l'as pas, commence par vérifier la version de l'appli.

@jmarcet
Copy link

jmarcet commented May 29, 2022

Hi Djuuu,

How do you get the /dev/shm/LogitechMXMaster3HScroll ?

@Sebelino
Copy link

@jmarcet That's just a small temporary file. You can create it yourself it it already exists. If you don't have a /dev/shm/, you can alternatively store the file below /tmp/. In my own version of the script, I am creating the file if it doesn't already exist.

@jmarcet
Copy link

jmarcet commented May 31, 2022

@Sebelino Yeah, my bad, I had an error in the script and for a moment I thought it was something like the synaptics driver has.

Anyhow, once I saw it working I don't see any benefit from it, you can get the same kind of delay directly with xdotool like xdotool key --delay 100 Control_L+Tab. I don't see any difference either by adding release to the button event.

I'm still looking for a way to get the TOP button as a modifier which I can then mix with the thumb wheel, and only do the Ctrl+Tab if pressed together.

@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