You are not logged in.

#1 2014-03-07 17:50:06

GNA
Member
Registered: 2011-02-15
Posts: 57

[SOLVED]Detect mouse existance

Hey,
Is there a way to detect if my mouse is currently plugged?

I know that udev lists add and remove. But if the mouse is plugged when the system is off there is none.

Thanks for help!

Last edited by GNA (2014-03-07 19:42:47)

Offline

#2 2014-03-07 17:56:55

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED]Detect mouse existance

lsusb, if it's a usb mouse.

Offline

#3 2014-03-07 18:28:05

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

Re: [SOLVED]Detect mouse existance

I disable a laptop's touchpad, if a mouse is connected, with this:

lsusb | grep -qi mouse && synclient TouchpadOff=1

Offline

#4 2014-03-07 19:36:54

GNA
Member
Registered: 2011-02-15
Posts: 57

Re: [SOLVED]Detect mouse existance

Thank you! This completely solves my issues!
I'll add this to the wiki so others may find it.
==> https://wiki.archlinux.org/index.php/To … _detection

Last edited by GNA (2014-03-07 19:44:52)

Offline

#5 2014-03-07 21:13:12

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 749

Re: [SOLVED]Detect mouse existance

@GNA: have you even tried the udev rules provided on the wiki? udev can detect device add/remove events even across suspend.

Offline

#6 2014-03-07 21:31:30

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

Re: [SOLVED]Detect mouse existance

lahwaacz wrote:

udev can detect device add/remove events

Yes, but using lsusb *when* convenient, is easier than writing a udev rule to keep track of the USB "add" event that udev would fire at system bootup.

Offline

#7 2014-03-07 21:49:17

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 749

Re: [SOLVED]Detect mouse existance

brebs wrote:
lahwaacz wrote:

udev can detect device add/remove events

Yes, but using lsusb *when* convenient, is easier than writing a udev rule to keep track of the USB "add" event that udev would fire at system bootup.

Alright, I'm just saying that it is nonsense to put it into crontab: https://wiki.archlinux.org/index.php?ti … did=303516
The best place for such command is .xinitrc, that way you will have the touchpad turned off as soon as X starts and udev will handle future (dis)connections.

Btw, I have the following in my .xinitrc:

if [ $(ls /dev/input | grep mouse | wc -l) -gt 1 ]; then
    synclient TouchpadOff=1
fi

Offline

Board footer

Powered by FluxBB