I have a USB powered light that I plugged into my computer. I would like to control the light from the terminal and I thought this would be straightforward.
Unfortunately this proved to be impossible without some additional hardware as the usb light is a dumb usb.
The light uses just power from the computer and so Linux never sees the device even when it is plugged in. This means that there is no way currently to use the software to turn off power to the usb.
I did try to figure out if I could turn off power to the port. This involved using a usb stick and plugging it in a few times and watching how lsusb -t
changes.
This way I could find out the bus and port number that I was trying to use.
lsusb -t
would show:
/: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/10p, 480M
|__ Port 006: Dev 006, If 0, Class=Vendor Specific Class, Driver=[none], 12M
|__ Port 006: Dev 006, If 2, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 007: Dev 007, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 003: Dev 008, If 0, Class=Human Interface Device, Driver=usbhid, 12M
I could then turn off the usb port by doing:
echo 1-4 | sudo tee /sys/bus/usb/drivers/usb/unbind
When the usb stick was used, it would disappear from lsusb
and from lsblk
.
The light on the usb however would stay on. I tried doing this and then plugging in my light but that didn't work.
You can turn the port back on by doing:
echo 1-4 | sudo tee /sys/bus/usb/drivers/usb/bind
I think putting some device inbetween my light and the computer is going to be the best bet.