summaryrefslogtreecommitdiff
path: root/bin/fixmouse.sh
blob: b9a8a362bfb464948f6e7522a6f1384f2497b046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#
# This is needed to load a third-party driver that duplicates but conflicts
# with the mainline MagicTrackpad driver. The changes from this driver are in
# mainline as of 4.20 so this can be removed then.
#

#
# Should be run as root from a udev hook
# Also needs to be run as the user to set xinput settings
#
# /etc/udev/rules.d/83-magicmouse.rules
# KERNEL=="mouse[0-9]*", SUBSYSTEM=="input", ATTRS{uniq}=="04:4b:ed:eb:0d:d8", RUN+="/home/ANT.AMAZON.COM/crutem/bin/fixmouse.sh"

if (( $EUID == 0 )); then
    if ! lsmod | grep hid_magicmouse &>/dev/null; then
        >&2 echo "Loading Magic Mouse Driver"
        insmod $(realpath ~crutem/.local/lib/hid-magicmouse.ko)
        sleep 2
    fi

    POINTER=$(for m in /dev/input/mouse*; do udevadm info $m | grep DEVPATH= | egrep -o '0005:004C:0265.[0-9A-F]+'; done)

    if [ ! -d "/sys/bus/hid/drivers/magicmouse/$POINTER" ]; then
        echo "$POINTER" > /sys/bus/hid/drivers/hid-generic/unbind
        echo "$POINTER" > /sys/bus/hid/drivers/magicmouse/bind
    fi
fi