ubuntu:mouse:determine_the_mouse
This is an old revision of the document!
Table of Contents
Ubuntu - Mouse - Determine the Mouse
Determine the Mouse to use
xinput --list --short
returns:
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard Consumer Control id=11 [slave pointer (2)] ⎜ ↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard Mouse id=12 [slave pointer (2)] ⎜ ↳ Razer Razer DeathAdder V2 id=8 [slave pointer (2)] ⎜ ↳ Razer Razer DeathAdder V2 Consumer Control id=9 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Power Button id=7 [slave keyboard (3)] ↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard id=10 [slave keyboard (3)] ↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard Consumer Control id=13 [slave keyboard (3)] ↳ Razer Razer DeathAdder V2 Consumer Control id=14 [slave keyboard (3)] ↳ Razer Razer DeathAdder V2 Keyboard id=15 [slave keyboard (3)] ↳ Razer Razer DeathAdder V2 System Control id=16 [slave keyboard (3)] ↳ Razer Razer DeathAdder V2 id=17 [slave keyboard (3)]
NOTE: In this case, the “Razer Razer DeathAdder V2” is the mouse.
- As there are multiple entries, the name “Razer Razer DeathAdder V2” cannot be used as it is not unique.
- Instead, use the id.
- How to know which of the id to use.
Which id to use
In the above results, the Razer DeathAdder is shown multiple times.
- Only the salient id is needed.
xinput | grep -m 1 "DeathAdder"
returns:
⎜ ↳ Razer Razer DeathAdder V2 id=8 [slave pointer (2)]
NOTE: Many mouse show as as both Mouse and Keyboard.
- The Keyboard entries can usually be ignore.
- -m 1 in the grep returns only the first line.
- This shows that id=8 is the relevant line.
- This id may change upon system reboot, so for any future scripts using the id, it is best this is calculated beforehand:
xinput | grep -m 1 "DeathAdder" | sed 's/^.*id=\([0-9]*\)[ \t].*$/\1/'
- returns:
8
ubuntu/mouse/determine_the_mouse.1635151918.txt.gz · Last modified: 2021/10/25 08:51 by peter