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
@av-emogai
Copy link

av-emogai commented Mar 7, 2024

This is simple and elegant solution, should have worked, but got stuck and not working.
I also get the following warning

WARNING: running xinput against an Xwayland server. See the xinput man page for details.
Digging into this pesky issue, this iswhat I have done so far:

  1. Install input-remapper-daemon -- but service fails to start with the following error
evdev.uinput.UInputError: "/dev/uinput" does not exist or is not a character device file - verify that the uinput module is loaded
Mar 07 16:50:35  input-remapper-service[16045]: Stopping all injections
  1. Tried to install input-remapper service -- that did not start either.
    Is there a simple fix for this on Xwayland Server?

image

@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