HOWTO static USB mouse
From Gentoo Linux Wiki
Contents |
[edit] Why would I want this?
Well if you have a laptop and have different settings for you USB-mouse as for you touchpad. It is a nice thing to have symlinks that point to the right mouse for your USB mouse and for you touchpad. For example what you boot your kernel your USB devices are recognised before your PS/2 devices. So if you forget to insert your USB mouse it is recognised after and your settings in your xorg.conf will be completely useless. So you would need a reboot. And well we do not want that. If we wanted to reboot we would use windows.
[edit] Get the info
Now run the command
# udevinfo -a -p `udevinfo -q path -n [path]`
where on path you insert your USB-mouse/touchpad.
Now we get a whole list of information. We need to look at it for our information and write down:
- KERNEL
- BUS
- SYSFS{modalias}
- the link to the dir our device is inside /dev
[edit] Example
In my case my USB-mouse at the moment is on /dev/input/mouse1 so I enter:
# udevinfo -a -p `udevinfo -q path -n /dev/input/mouse1`
And this is the top of my output:
device '/sys/class/input/input2/mouse1' has major:minor 13:33
looking at class device '/sys/class/input/input2/mouse1':
KERNEL=="mouse1"
SUBSYSTEM=="input"
SYSFS{dev}=="13:33"
follow the "device"-link to the physical device:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:03.0/usb1/1-1/1-1:1.0':
BUS=="usb"
ID=="1-1:1.0"
DRIVER=="usbhid"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceClass}=="03"
SYSFS{bInterfaceNumber}=="00"
SYSFS{bInterfaceProtocol}=="02"
SYSFS{bInterfaceSubClass}=="01"
SYSFS{bNumEndpoints}=="01"
SYSFS{modalias}=="usb:v046DpC016d0340dc00dsc00dp00ic03isc01ip02"
So I need:
- KERNEL = "mouse1"
- BUS = "usb"
- SYSFS{modalias} = "usb:v046DpC016d0340dc00dsc00dp00ic03isc01ip02"
- Link = "input"
[edit] Now let udev handle it!
(ayqazi:) Note that assigning to NAME as done previously is unnecessary and confusing
(JoeR410:) In theory, you shouldn't be able to combine Kernel, Bus, and SYSFS{modalias} for a rule. See this site for some good information on writing udev rules.
So you got through the hardest part? Good for you! Now lets move on. With your favorite text editor edit/create: /etc/udev/rules.d/10-local.rules
Now insert [syntax]
BUS=="[BUS]", SYSFS{modalias}=="[SYSFS{modalias}]", KERNEL=="[KERNEL]", SYMLINK+="[SYMLINK]"
Now we can go substitue:
- [BUS]
- replace this with the bus you wrote down above
- [SYSFS{modalias}]
- replace with the SYSFS{modalias} what you wrote down above.
- [KERNEL]
- replace with the 'KERNEL' you wrote down above only change the digit into an ?
- [SYMLINK]
- replace with the sublink you want to create
[edit] Example
In my case /etc/udev/rules.d/10-local.rules for my usb mouse would look like:
BUS="usb", SYSFS{modalias}=="usb:v046DpC016d0340dc00dsc00dp00ic03isc01ip02", KERNEL=="mouse?", SYMLINK="input/usbmouse"
I created a symlink to my usbmouse inside /dev/input/usbmouse. Wich will be created when I insert my USB mouse and delete when I unplug it.
[edit] And now what?
Now you can go to your xorg.conf and substitute the link to your old device with the symlink you have created. That way it does not matter what was recognized first: the USB-mouse or the touchpad.
[edit] FAQ
- Why do I need to replace the digit with a ? ?
- Since we do not know where it will be located (else we would not need the symlink) we use this wildcard.
- Can I leave the NAME ?
- No! you can't then it will point to the event which is not where you want your symlink to point to.
- Can I use something else than SYSFS{modalias}
- I did not test it but I think it is possible. It just has to be an unique thing of the mouse.
- I do not have a laptop only a desktop
- well that way you won't need this how to since your desktop will only have one mouse.
