You are not logged in.

#1 2014-07-23 19:43:16

Dekusola
Member
Registered: 2014-07-12
Posts: 3

Problem with udev rule to disable touchpad when USB mouse connects

Hi, I've been running Arch on this laptop, but I can't get this udev rule to work properly.

What I want to happen is: when I plug in my usb mouse, the laptop touchpad is disabled, and the left and right buttons are reversed (I'm left handed)

After following several tutorials, both from the arch wiki and other sites, I've come up with this udev rule:

ACTION=="add", SUBSYSTEM=="input", RUN+="/usr/local/bin/USBMouse.sh"
ACTION=="remove", SUBSYSTEM=="input", RUN+="/usr/local/bin/USBMouse.sh"

And here's the script it links to (USBMouse.sh):

#!/bin/bash
export DISPLAY=:0.0
synclient TouchPadOff=$(/usr/bin/lsusb | grep "Microsoft Corp.\
 Nano Transceiver v1.0 for Bluetooth" | wc -l)

if [[ $(/usr/bin/lsusb | grep "Microsoft Corp.\
 Nano Transceiver v1.0 for Bluetooth" | wc -l) == 1 ]]
        then
                xmodmap -e 'pointer = 3 2 1'
fi

if [[ $(/usr/bin/lsusb | grep "Microsoft Corp.\
 Nano Transceiver v1.0 for Bluetooth" | wc -l) == 0 ]]
        then
                xmodmap -e 'pointer = 1 2 3'
fi

Running the script from a terminal returns no errors and works as expected. The problem is when I plug/unplug the mouse from the usb port, nothing happens.

I appreciate any insight you might have about how to fix this, and thank you in advance smile

Offline

#2 2014-07-23 19:54:24

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Problem with udev rule to disable touchpad when USB mouse connects

This has already been done. And another relevant thread.

Offline

Board footer

Powered by FluxBB