Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Disable USB port ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Wed Oct 23, 2019 12:25 pm    Post subject: Disable USB port ? Reply with quote

Got a new mouse, and it has a very bright light coming out of it, mostly through scroll wheel, it makes problems during a night when I go to sleep.
Now, I know I can cover it with something or plug it off, or open it and do something with it etc.
But I'm wondering is there a way to disable USB port via some terminal command, piece of software or something like that, because I would prefer that option first.
I tried to google it, there was one option with powertop, that didn't work, then few commands via terminal, that didn't work as well, mostly because the posts were old and it was for older kernels.
So, can it be done ?
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1982
Location: Frankfurt, Germany

PostPosted: Wed Oct 23, 2019 12:31 pm    Post subject: Reply with quote

What about uhubctl? https://github.com/mvp/uhubctl
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Wed Oct 23, 2019 12:43 pm    Post subject: Reply with quote

Have problems with that one, posted issue there yesterday.
https://github.com/mvp/uhubctl/issues/183
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7368

PostPosted: Thu Oct 24, 2019 12:31 pm    Post subject: Reply with quote

Code:
dmesg
...
[ 4963.102582] input: Logitech USB Laser Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-13/1-13:1.0/0003:046D:C062.0005/input/input17

the thing to get is that the mouse is input17 (for now)

off: echo remove > /sys/class/input/input17/event0/uevent
on: echo add > /sys/class/input/input17/event0/uevent
ps: i don't have a fancy light to see if it power it off for real, but at least, the mouse stop working in the UI
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Thu Oct 24, 2019 12:43 pm    Post subject: Reply with quote

It disabled the mouse, but the light was still on.
Thanks for trying!
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7368

PostPosted: Thu Oct 24, 2019 12:57 pm    Post subject: Reply with quote

well, i'm not in mood for disabling my whole usb port holding the mouse, but if you're in, maybe disable the usb port the mouse is attach to would do
you can get it with udevadm info /sys/class/input/input17
ps: of course you better make sure your keyboard isn't attach to that port too, else, you will have a little problem trying to send the add event next :)
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Thu Oct 24, 2019 1:23 pm    Post subject: Reply with quote

I'm in the mood :)

I don't get it how to disable the port though, here's the output :
Code:
$ udevadm info /sys/class/input/input11
P: /devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0001/input/input11
E: DEVPATH=/devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0001/input/input11
E: EV=17
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_MOUSE=1
E: ID_MODEL=USB_OPTICAL_MOUSE
E: ID_MODEL_ENC=\x20USB\x20OPTICAL\x20MOUSE
E: ID_MODEL_ID=0538
E: ID_PATH=pci-0000:01:00.0-usb-0:4:1.0
E: ID_PATH_TAG=pci-0000_01_00_0-usb-0_4_1_0
E: ID_REVISION=0100
E: ID_SERIAL=0000_USB_OPTICAL_MOUSE
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
E: ID_USB_INTERFACES=:030102:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=0000
E: ID_VENDOR_ENC=0000
E: ID_VENDOR_ID=0000
E: KEY=70000 0 0 0 0
E: MODALIAS=input:b0003v0000p0538e0111-e0,1,2,4,k110,111,112,r0,1,8,B,am4,lsfw
E: MSC=10
E: NAME=" USB OPTICAL MOUSE"
E: PHYS="usb-0000:01:00.0-4/input0"
E: PRODUCT=3/0/538/111
E: PROP=0
E: REL=903
E: SUBSYSTEM=input
E: UNIQ=""
E: USEC_INITIALIZED=6241323
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6342

PostPosted: Fri Oct 25, 2019 8:39 am    Post subject: Reply with quote

You can tell the kernel to put it in powersaving mode automatically after a timeout, which should kill the LED until you wake it up with a click.

Here's a config file I use for mine:
/etc/udev/rules.d/local-usb.rules:

ACTION!="add|change", GOTO="local_usb_end"
SUBSYSTEM!="usb", GOTO="local_usb_end"

# keyboard
ATTR{idVendor}=="045e", ATTR{idProduct}=="00db", ATTR{power/control}="auto", ATTR{power/autosuspend}="300"
# mice
ATTR{idVendor}=="045e", ATTR{idProduct}=="0039", ATTR{power/control}="auto", ATTR{power/autosuspend}="900"
ATTR{idVendor}=="045e", ATTR{idProduct}=="076c", ATTR{power/control}="auto", ATTR{power/autosuspend}="900"
# tablet
ATTR{idVendor}=="172f", ATTR{idProduct}=="0031", ATTR{power/control}="auto" # default timeout of 5 is fine

LABEL="local_usb_end"
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Fri Oct 25, 2019 9:06 am    Post subject: Reply with quote

Doesn't work, after I made that file I did '/etc/init.d/udev reload' , hope that was enough.
btw I changed timeouts to 5, just to test it out.

Is idProduct relevant maybe or something else in that config that I should perhaps change ?

edit:
I changed idVendor to 0000 and idProduct to 0538, but still no luck
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7368

PostPosted: Fri Oct 25, 2019 1:12 pm    Post subject: Reply with quote

kajzer wrote:
Code:
P: /devices/pci0000:00/:00:010000.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0001/input/input11

/sys/class/pci_bus/0000:00/device/00:010000.2/usb1/
(but your path have another bus 0000:01:00.0 in between so i'm less sure about the path, seek usb1 name to find the right path, you have the product file to see if its the controller and the uevent file there to try disable it)
Code:
pwd
/sys/class/pci_bus/0000:00/device/0000:00:14.0/usb1
cat product
xHCI Host Controller
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Fri Oct 25, 2019 4:01 pm    Post subject: Reply with quote

Well, I get what you're saying and what needs to be done, but having a hard time finding that path.
There are many combinations and seems like I have to manually go through each in order to find the right one.
Can't really deal with that at the moment so I'll try it when I can.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6342

PostPosted: Fri Oct 25, 2019 11:12 pm    Post subject: Reply with quote

Your mouse also needs to be powersaving-capable. Chances are they skipped that part, because they couldn't even be bothered to get a real vendor ID.
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Sat Oct 26, 2019 12:16 am    Post subject: Reply with quote

When I say it doesn't work I mean the light is still on but the mouse is disabled.
It's like doing it the other way krinn suggested.
I mean here's the log , it gets disabled, it gets enabled again on move/click.
Code:
[  +0.411666] usb 1-4: new low-speed USB device number 8 using xhci_hcd
[  +0.315088] input:  USB OPTICAL MOUSE as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0006/input/input17
[  +0.000102] hid-generic 0003:0000:0538.0006: input,hidraw0: USB HID v1.11 Mouse [ USB OPTICAL MOUSE] on usb-0000:01:00.0-4/input0
[ +12.874338] usb 1-4: USB disconnect, device number 8
[  +0.408244] usb 1-4: new low-speed USB device number 9 using xhci_hcd
[  +0.315759] input:  USB OPTICAL MOUSE as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0007/input/input18
[  +0.000120] hid-generic 0003:0000:0538.0007: input,hidraw0: USB HID v1.11 Mouse [ USB OPTICAL MOUSE] on usb-0000:01:00.0-4/input0
[  +7.291391] usb 1-4: USB disconnect, device number 9
[  +0.407475] usb 1-4: new low-speed USB device number 10 using xhci_hcd
[  +0.316221] input:  USB OPTICAL MOUSE as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0008/input/input19
[  +0.000118] hid-generic 0003:0000:0538.0008: input,hidraw0: USB HID v1.11 Mouse [ USB OPTICAL MOUSE] on usb-0000:01:00.0-4/input0
[ +14.233223] usb 1-4: USB disconnect, device number 10
[  +0.393021] usb 1-4: new low-speed USB device number 11 using xhci_hcd
[  +0.314932] input:  USB OPTICAL MOUSE as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.0009/input/input20
[  +0.000242] hid-generic 0003:0000:0538.0009: input,hidraw0: USB HID v1.11 Mouse [ USB OPTICAL MOUSE] on usb-0000:01:00.0-4/input0
[  +9.986627] usb 1-4: USB disconnect, device number 11
[  +0.410938] usb 1-4: new low-speed USB device number 12 using xhci_hcd
[  +0.317095] input:  USB OPTICAL MOUSE as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-4/1-4:1.0/0003:0000:0538.000A/input/input21
[  +0.000124] hid-generic 0003:0000:0538.000A: input,hidraw0: USB HID v1.11 Mouse [ USB OPTICAL MOUSE] on usb-0000:01:00.0-4/input0


That's why I think that disabling the port power is the way to go.
Telling the kernel that specific usb port doesn't exist, if possible.


Last edited by kajzer on Sat Oct 26, 2019 12:21 am; edited 1 time in total
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7501
Location: Saint Amant, Acadiana

PostPosted: Sat Oct 26, 2019 12:19 am    Post subject: Reply with quote

How about taking that mouse apart and applying a piece of tape or nail polish on that LED. :P
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Sat Oct 26, 2019 12:22 am    Post subject: Reply with quote

Jaglover wrote:
How about taking that mouse apart and applying a piece of tape or nail polish on that LED. :P


Eventually that's going to happen :D
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7414
Location: almost Mile High in the USA

PostPosted: Sat Oct 26, 2019 12:54 am    Post subject: Reply with quote

A lot of computers cannot disable the power on USB ports while the computer is on.
A lot of mice do not know how to deal with power save.

Chances are, removing/masking the LED and/or replacing the sensor illumination LED with an infrared one is all you can do.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
kajzer
l33t
l33t


Joined: 27 Nov 2014
Posts: 660

PostPosted: Sat Oct 26, 2019 6:05 pm    Post subject: Reply with quote

Yeah, well I kinda like the light when I'm not sleeping, was hoping that maybe there's a way.
Maybe I'll find it, not really in a rush, will not give up, for now covering the mouse with dark cloth works fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum