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
This does not work for me. (Ubuntu 18.04.1 LTS). Installation goes without errors. I created a file ~/.xbindkeysrc with the text
"echo -n | xsel -n -i; pkill xbindkeys; xdotool click 2; xbindkeys"
b:2 + Release
I than ran xbindkeys -p. But I still paste with the middle mouse button.
I checked that b:2 is indeed the middle mouse button for me with xev:
"ButtonRelease event, serial 37, synthetic NO, window 0x4a00001, root 0x240, subw 0x0, time 15972433, (105,113), root:(1029,535), state 0x200, button 2, same_screen YES"
Any ideas what could be wrong? How can I make this work?
Update: I removed the "+ Release" and now it seems to work.