DEV Community

Brama Udi
Brama Udi

Posted on • Updated on

Enabling Mouse Middle Click Emulation in Linux

What i mean about "Middle Click Emulation"? Hmm, this is like a feature that allow you to emulate a middle click when pressing left and right buttons simultaneously, really good if you hate/have broken mouse wheel click.

As i remember some Linux like "Linux Mint" enable it by default, but if you try on your current Linux OS and it doesn't work then follow these step to enable.

Prerequisite

  • xinput installed, i.e. if you are on Debian you can install it with apt package manager when don't have it, apt-get install xinput.

Steps

1.) Find your mouse device ID

xinput
Enter fullscreen mode Exit fullscreen mode

In my case the mouse ID are 8

xinput output

2.) Find mouse "emulate" props ID

xinput list-props 8
Enter fullscreen mode Exit fullscreen mode

In result above we've found props ID for Emulate Middle Click is 265 and they still have a 0 value.

xinput-list-props

3.) To enable it lets change the Emulate Middle Click value to 1

xinput set-prop 8 265 1
Enter fullscreen mode Exit fullscreen mode

xinput-set-prop

Thats all, you can place the last command xinput set-prop 8 265 1 to $HOME/.profile or $HOME/.bashrc file for persistent changes after reboot.


UPDATE: Recently i use GNOME desktop environment and use Wayland session, the xinput's result keep showing me some virtual devices like this

Wayland xinput result

... and of course make the tutorial above is meaningless, then the solution here is just paste the command below:

gsettings set org.gnome.desktop.peripherals.mouse middle-click-emulation true
Enter fullscreen mode Exit fullscreen mode

Reference:

libinput-force-middle-click-emulation

Top comments (0)