Ubuntu – Making the xinput –set-button-map changes permanent


I have a new mouse which runs on bluetooth, but I had to setup the middle mouse button manually using xinput --set-button-map. This isn't persistent after reboot, so I wrote a small python script to run it automatically after login. Unfortunately, it doesn't work because there is some delay before the mouse automatically reconnects after login.

I thought of just adding some wait into my script, but I'm sure there must be a better way to do this. Can I hook into connect events from /usr/sbin/bluetoothd or something like that instead?

Best Answer

  • I put some wait time and retries into my script and lived with that for a few days, but this weekend I had some spare time to find the "correct" solution.

    That is, add the button map into a config file for X.

    Section "InputClass"
        Identifier  "Logitech MX Revolution Mouse"
        Option  "ButtonMapping" "1 2 3 4 5 6 7 9 8 10 11 12 13 14 15 2 17 18 19 20 21 22 23 24"

    Hopefully this helps someone else one day.