I am using Magic Mouse 2 with ubuntu 20.04. To use the scrolling feature, I had to install this driver: https://github.com/rohitpid/Linux-Magic-Trackpad-2-Driver. The only problem is that I need to execute these two lines every time I restart or reconnect the mouse via bluetooth:
echo "0005:004C:0269.0008" > /sys/bus/hid/drivers/magicmouse/unbind
echo "0005:004C:0269.0008" > /sys/bus/hid/drivers/magicmouse/bind
If I did not unbind then bind after the mouse is connected, I could still use the magic mouse but the scrolling won't work.
Anyways, I was looking for a way to automate this whenever the mouse is connected via bluetooth. I found out about udev but could not get it to work without getting into infinite loop. Here is the content of my hid-magicmouse.rules
file under /etc/udev/rules.d
:
ACTION=="bind", KERNEL=="0005:004C:0269.*", SUBSYSTEM=="hid", DRIVER=="magicmouse", \
RUN+="/bin/bash -c 'echo $kernel > /sys/bus/hid/drivers/magicmouse/unbind'", \
RUN+="/bin/bash -c 'echo $kernel > /sys/bus/hid/drivers/magicmouse/bind'"
This gets into an infinite loop because the script will call itself again after executing the second line (bind command) which is the triggering action for this rule.
I tried changing the triggering action to "add" instead of "bind", but scrolling still does not work.
Here is the output of my udevadm monitor
when the magic mouse is connected:
KERNEL[1684.898183] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12 (bluetooth)
UDEV [1684.905964] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12 (bluetooth)
KERNEL[1685.029515] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008 (hid)
KERNEL[1685.029970] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/input/input494 (input)
KERNEL[1685.030138] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/input/input494/mouse1 (input)
KERNEL[1685.030418] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/input/input494/event15 (input)
KERNEL[1685.030510] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/hidraw/hidraw5 (hidraw)
UDEV [1685.034983] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008 (hid)
UDEV [1685.042271] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/input/input494 (input)
UDEV [1685.050656] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/hidraw/hidraw5 (hidraw)
UDEV [1685.050881] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/input/input494/mouse1 (input)
UDEV [1685.088633] add /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008/input/input494/event15 (input)
KERNEL[1685.627176] bind /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008 (hid)
UDEV [1685.632050] bind /devices/pci0000:00/0000:00:1e.0/dw-apb-uart.2/serial1/serial1-0/bluetooth/hci0/hci0:12/0005:004C:0269.0008 (hid)
Any help to automate or fix this is appreciated!
0 Answers