Source

small_scripts / xmodmap_logitech_mouse_buttons.sh

#!/bin/sh

# 046d:c049 Logitech, Inc. G5 Laser Mouse
#    _______
#   /  | |  \   Scroll:
#  | 1 |2| 3 |    4
#  |   |_|   |  6<@>7
#  |         |    5
# []9        |
#  |         |
# []8        |
#  |         |
#   \_______/


# Changes:
# * Side buttons are now middle-click (8,9 = 2)

# For some reason, this command is giving me:
#xmodmap -e 'pointer = 1 2 3 4 5 6 7 2 2'
# X Error of failed request:  BadValue (integer parameter out of range for operation)
#   Major opcode of failed request:  116 (X_SetPointerMapping)
#   Value in failed request:  0x2
#   Serial number of failed request:  9
#   Current serial number in output stream:  9

MOUSE_ID=`xinput list | sed -n 's/.*Logitech USB Gaming Mouse.*id=\([0-9]\+\)[^0-9].*/\1/p'`

if [ -z "$MOUSE_ID" ] ; then
  echo 'Logitech Mouse not found'
  exit 1
fi

xinput set-button-map "$MOUSE_ID" 1 2 3 4 5 6 7 2 2

# See also:
# https://github.com/cemmanouilidis/naturalscrolling
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.