You are not logged in.

#1 2013-03-23 12:06:41

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

[solved] Finding my mouse in /sys

Thing is, I want to toggle the power of my mouse. I do this by writing "auto" or "on" in the power/control file associated to the device. All that is fine. Until now, I just used "/sys/bus/usb/devices/7-2/power/control" and it worked.

Of course, after a reboot the mouse in now under 5-2 (instead of 7-2) so it doesn't work anymore. I'm guessing this is the usual "random loading" of the kernel, similar to /dev/sd? which means I'm looking for the UUID equivalent, but for my mouse (an USB device, obviously).

I'm not really familiar with the /sys fs, so I'm not sure how it works/where to look. So far I found that I could use this: /sys/class/input/mouse0/../../../../power/control
It works, and I'm assuming that, having only one mouse, it should always be named mouse0 and that might always work, but I don't know for sure. Would that be right? And if not, where/how should I do, to find a reliable path to the power/control file for my USB mouse?

Thanks.

Last edited by jjacky (2013-03-23 13:02:17)

Offline

#2 2013-03-23 12:18:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,498
Website

Re: [solved] Finding my mouse in /sys

Do you want this reliable for your own use, or do you intend to distibute a tool that should work for anyone?  If the former, it sounds like you've got it.

You could also explore /sys/devices/virtual/input/mice/*


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2013-03-23 12:29:12

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: [solved] Finding my mouse in /sys

I did also found /sys/devices/virtual/input/mice/subsystem/mouse0/../../../../power/control to be usable, but it seems to just be a longer version of the same thing, also relying on mouse0.

Anyhow, it's just for my own use, yes.
Thanks.

Offline

#4 2013-03-23 12:31:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,498
Website

Re: [solved] Finding my mouse in /sys

Oh, I was thinking (path)/mice/power/control - it seems like it would be for all mice, but I haven't tested it.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2013-03-23 12:53:59

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: [solved] Finding my mouse in /sys

Oh, yeah I tried to write in that file (/sys/devices/virtual/input/mice/power/control) but it didn't actually do anything, for some reason. That is, I could e.g. write "auto" (a cat confirms this), but the mouse wouldn't be affected by it.

Offline

Board footer

Powered by FluxBB