8

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?

wim
  • 12,738

2 Answers2

8

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.

#/usr/share/X11/xorg.conf.d/logitech-mx-revolution.conf

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"
EndSection

Hopefully this helps someone else one day.

wim
  • 12,738
  • 2
    User Configuration is supposed to go to /etc/X11/xorg.conf.d/ – user56452 Aug 01 '14 at 12:28
  • 2
    @user56452 actually, since 10.10, Ubuntu does use /usr/share/ for X11 user config. (I thought the same thing, actually, so I proposed an edit for this answer. Then 3 seconds later I found that wiki page. oops!) – Austin Adams Jul 19 '15 at 02:18
  • 2
    @AustinAdams i dont see it. from that link: Users can continue making custom configuration in /etc/xorg.conf as usual; the .conf snippets are mainly there for the distro or hw vendor to ship default InputClass rules and custom overrides. " – user56452 Jul 26 '15 at 15:56
  • @user56452 well, this is doubly embarrassing -- you're right! On a 14.04 machine, I created /etc/X11/xorg.conf.d/, and Xorg applied a config file I placed there. (why did I doubt the manpage?!) The question, then, is if /etc/ is a better choice for user configuration than /usr/share/. In principle, I'd say "absolutely," but I don't use Ubuntu. What do you think, @wim? – Austin Adams Jul 27 '15 at 02:25
  • I think it's an inconsequential and trivial aspect of the issue. It seems like either location works - if /usr/share/X11 ever stops working someone can feel free to edit my answer. – wim Jul 27 '15 at 11:07
  • It specifically says it's prone to be overwritten.

    DO NOT EDIT THIS FILE, your distribution will likely overwrite

    it when updating. Copy (and rename) this file into

    /etc/X11/xorg.conf.d first.

    – Dessa Simpson Sep 09 '16 at 02:19
  • @VirtualDXS Not for me. I created the file. – wim Sep 12 '16 at 03:22
  • Thanks! That was the only way that was persistent over standby/resume for me - putting it in .xsession etc only worked on login, but was reset to defaults after resume – Matija Nalis Aug 21 '17 at 20:08
1

I have a Logitech Ultrathin Touch and I got the remapping to work with:

/etc/X11/xorg.conf.d/10-evdev.conf # # custom for logitech ultrathin mouse

Section "InputDevice"
    Identifier "Logitech bluetooth Touch Mouse"
    Driver "evdev"
    Option "Name"   "Ultrathin Touch Mouse"
    Option "ButtonMapping" "1 1 3 4 5 6 7 0 0 0 0 0 0"
EndSection


Section "InputClass"
    Identifier  "Ultrathin Touch Mouse"
    Option "ButtonMapping" "1 1 3 4 5 6 7 0 0 0 0 0 0"
EndSection

Not sure if all of this is needed but after a day of wrestling with this i'm just relieved that something works... I've found now that horizontal scrolling is a little slower than i'd like. so i'll probably see if there's some option to configure that.

steev
  • 239
  • 1
  • 4