Skip to content

Instantly share code, notes, and snippets.

@claudiobizzotto
Created February 5, 2017 18:05
Show Gist options
  • Save claudiobizzotto/5badae152e6b8002a2516a72d804f73e to your computer and use it in GitHub Desktop.
Save claudiobizzotto/5badae152e6b8002a2516a72d804f73e to your computer and use it in GitHub Desktop.
Quick, dirty and cheap way to get a left-handed mouse on Linux

Free left-handed mouse

Quick, dirty and cheap way to get a left-handed mouse on Linux (tested on Ubuntu only).

Installation

Just place this function in your ~/.bash_aliases file:

# Left-handed mouse buttons
function left_hand_mouse () {
  xinput list | grep -e "id\=.*slave\s*pointer" | while read -r LINE ; do
    DEVICE_NAME=$(echo "$LINE" | cut -f 1)
    DEVICE_ID=$(echo "$LINE" | cut -f 2 | cut -d= -f 2)
    echo -e "Switching mouse button for $DEVICE_NAME\tDEVICE ID = $DEVICE_ID"
    xinput set-button-map $DEVICE_ID 3 2 1
  done
}

Don't forget to source the changes:

$ . ~/.bashrc

Usage

To switch the mouse button positions to left-handed, call the function from the terminal:

$ left_hand_mouse
@claudiobizzotto
Copy link
Author

My script is very old--there was no Wayland back then. I also stopped using it once companies started manufacturing high quality left-handed mice, such as this one.

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