Skip to content

Instantly share code, notes, and snippets.

@sam0x17
Last active July 30, 2023 18:17
Show Gist options
  • Save sam0x17/f1d89df55778e4317d8974623a62e8c6 to your computer and use it in GitHub Desktop.
Save sam0x17/f1d89df55778e4317d8974623a62e8c6 to your computer and use it in GitHub Desktop.
disable middle-click paste in linux without disabling middle scroll

Disable middle-click paste in Linux

Install packages:

sudo apt-get install xbindkeys xsel xdotool

Create xbindkey configuration file:

# ~/.xbindkeysrc
"echo -n | xsel -n -i; pkill xbindkeys; xdotool click 2; xbindkeys"
b:2 + Release

Set xbindkeys to load on startup:

# ~/.bashrc
xbindkeys -p

Log out, log back in, and you should be all set. If you are impatient, simply run xbindkeys -p

@Joey-Pepperoni
Copy link

Hey, so it actually does work. I don't no why it didn't work for a while, but after a resets it has been working fine through multiple reboots. So no problem, i don't know what the problem was, but it's gone now.

@Joey-Pepperoni
Copy link

Sorry to cuase an issue when there wasn't one. I probably just set up /.xbindkeyssrc wrong or something like that. But this solution DOSE work.

@sauliusGTO3000
Copy link

thank you! I wasted 15 minutes to operate out this leftover from the past, so I can use my other leftover from the past - the trackpoint to scroll my IDE without pasting snippets all over the place :)

@joacopaz
Copy link

joacopaz commented Nov 3, 2022

You absolute gigachad. Thank you

@Wolfyxon
Copy link

Wolfyxon commented Jan 3, 2023

This is awesome! I can still use my mouse (even the middle click and scroll) and there's no annoying pastes. However middle button click event is slower by like 0.5s and that's annoying

@Sledmine
Copy link

Sledmine commented Jun 5, 2023

Any luck on removing that weird delay?

@ajayyy
Copy link

ajayyy commented Jul 30, 2023

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