Advertisement
NLinker

Remap buttons in Kensington Expert Mouse

Feb 11th, 2022
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.79 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # 1 "Button Left"
  4. # 2 "Button Middle"
  5. # 3 "Button Right"
  6. # 4 "Button Wheel Up"
  7. # 5 "Button Wheel Down"
  8. # 6 "Button Horiz Wheel Left"
  9. # 7 "Button Horiz Wheel Right"
  10. # 8 "Button Side"
  11. # 9 "Button Extra"
  12.  
  13. # The trackball has the following keys by default
  14. # ░░░░░░░░░░░░░
  15. # ░╔════╤════╗░
  16. # ░║░2░░│░░8░║░
  17. # ░║░░░▄▄▄░░░║░
  18. # ░╟───███───╢░
  19. # ░║░░░▀▀▀░░░║░
  20. # ░║░1░░│░░3░║░
  21. # ░╚════╧════╝░
  22. # ░░░░░░░░░░░░░
  23.  
  24. mouse_name="Kensington Expert Mouse"
  25.  
  26. check=$(xinput | grep "$mouse_name")
  27.  
  28. if [[ ! -z "$check" ]]; then
  29.     mouse_id=$(xinput | grep "$mouse_name" | sed "s/^.*id=\([0-9]*\)[ \t].*$/\1/")
  30.     echo "Device $mouse_id found"
  31.  
  32.     # Trackball button 1 will generate click 8 ("Button Side" interpreted as back)
  33.     # Trackball button 2 will generate click 1 ("Button Left")
  34.     # Trackball button 3 will generate click 9 ("Button Extra" interpreted as forward)
  35.     # Trackball button 8 will generate click 3 ("Button Right")
  36.     xinput set-button-map $mouse_id 8 1 9 4 5 6 7 3 2
  37.  
  38.     # we might want to enable better scrolling
  39.     # xinput set-prop $mouse_id "libinput Natural Scrolling Enabled" 1
  40.  
  41.     # disable acceliration for the ball
  42.     # xinput set-prop $mouse_id "libinput Accel Profile Enabled" 0, 1
  43.  
  44.     # allow scrolling by holding middle mouse button and using the ball to scroll ( really smooth and fast ).
  45.     # xinput set-prop $mouse_id "libinput Scroll Method Enabled" 0, 0, 1
  46.  
  47.     # allow the remmaped middle mouse to be used for middle mouse scroll
  48.     # xinput set-prop $mouse_id "libinput Button Scrolling Button" 3
  49. fi
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement