-   Linux - Hardware (
-   -   Which command to use to (temporarily) turn off the mouse? (

gus_1985 11-20-2008 06:15 AM

Which command to use to (temporarily) turn off the mouse?
Hi folks,

I've already googled for a solution to my problem, but to no avail.

Is there any command that allows me to deactivate the mouse completely until I decide to turn it on again?

My goal is to use xset dpms force off to shut off my display. However, even the slightest movement of the mouse causes it to turn on again. I'd like the system to do so only after a key is pressed.

Thanks in advance for any replies,


pinniped 11-20-2008 11:27 PM

My X setup uses /dev/input/mice - which means my USB trackball (preferred) or that horrible evil invention from the darkest depths of hell known as the 'touchpad'. Sometimes I can't plug in my trackball so I'll use the touchpad; however, most of the time when I boot that horrible touchpad screws me over because I bump it so often while typing.

So - the tricks are:
1. switch to a text virtual console (like vc1)
2. unload the mouse driver (for my cursed touchpad: rmmod psmouse)
3. do whatever you want to X

Now before starting X, just remember to activate the mouse driver again; do this from the text console just in case X gets a bit confused (although it shouldn't if you use 'mice' as I do).

gus_1985 11-21-2008 02:45 PM

Hi pinniped,

thanks very much for your fast reply. It completely deactives my notebook's touchpad.

But how do I proceed if I want to do the same with an USB mouse? After all, I cant' just unload the whole usbhid module, can I?

lsusb (debian) delivers:

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 04f9:01aa Brother Industries, Ltd DCP-540CN (printer)
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0d3d:0001 Tangtop Technology Co., Ltd HID Keyboard (keyboard)
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 1a7c:0068 <- This is the mouse.
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Any idea on how to accomplish that, i.e. how to turn off an usb mouse?

I already tried the approach mentioned in the link above:
However, in the directory

there is no subfolder

. Hence, I can't use

echo -n 0/2 > ./state
for on/off

pinniped 11-21-2008 04:20 PM

For the USB mouse, I set up 'udev' to always call it 'mouse0' (and the touchpad is always mouse1). I just pull out the USB mouse and plug it back in. You *have* to be in a virtual console when you plug the mouse back in, otherwise X has the mouse device open and udev can't name the mouse 'mouse0'; also, you don't want a million mouse devices which don't really exist because the USB mouse was plugged and unplugged multiple times - that would be a mouse infestation.

I don't have my laptop with me today so I can't look up the rule I used (and where I put it), but you start off with the /sys filesystem:

cd /sys/class/input
udevinfo -a -p $PWD/mouse0

Somewhere in there I get:
ATTRS{name}=="PS2++ Logitech TrackMan"

SO I can make a udev rule:
KERNEL=="mouse?", ATTRS{name}=="PS2++ Logitech TrackMan", NAME="mouse0"

gus_1985 11-21-2008 04:47 PM


Originally Posted by pinniped (Post 3350272)
I just pull out the USB mouse and plug it back in.

Unfortunately, that is exactly the thing I wanted to avoid :(.
The grand goal was to write a shell script that first turns the mouse off via command and then does the same with the display.

Besides, plugging the mouse in and out already works fine somehow.

pinniped 11-21-2008 05:51 PM

I can't think of how to disable the mouse without disabling keyboards as well. Unfortunately it looks like time to look at the driver code. It might be possible to write to a sysfs parameter to shut down the mouse. Otherwise the only other option I can think of is to have an enable/disable parameter in sysfs - that may be useful if other people have the same problem and find it too annoying.

gus_1985 11-23-2008 04:12 AM

Oh. I think that right now this is way over my head. I guess I'll just have to stick with plugging the mouse in and out.

Thanks for your efforts though, pinniped.

All times are GMT -5. The time now is 07:01 AM.