For years, I have been dealing with this Ubuntu bug where my mouse freezes soon after booting and then periodically freezes after that. To fix it, I have to physically unplug the usb transceiver for the mouse and plug it back in. From my research, this bug happens with USB wireless Windows mice when dual booting Linux and Windows.
Is there a way I can programmatically (from the terminal) unplug the USB transceiver instead of doing it physically? I want to achieve this in my startup bash script.
I'm using Ubuntu 16.04
Edit: I solved my problem but it doesn't really relate to my question.
In the file..
/etc/laptop-mode/conf.d/runtime-pm.conf
I had to make
CONTROL_RUNTIME_AUTOSUSPEND=0
This fixes the mouse bug I was experiencing for years.
Best Answer
I wrote a script to show how I’d do that:
First you need to get the bus and port number of the usb port in question. You can do that with
lsusb
and any device you recognize inlsusb
’s output, I use a Sandisk pendrive here:From the output of
lsusb
you get the bus and device number of the device, then search this device in the output oflsusb -t
to get the bus and port number (sometimes with subports). The syntax is:Use this as
port
in the script. Now you just need to make it executable withchmod +x /path/to/script
and run it with root permissions:I didn’t need one for my pendrive, but it may be necessary for you to add a delay between unbinding and binding again, that’s what the commented out
sleep 1
line is for – you can experiment with the values, e.g.sleep 0.5
for half a second.Note that this approach shows how to disable and enable again a certain USB port, if you want a specific device to be unbound and rebound again you’ll have to use the same USB port for this to work. One could think of a way to parse
lsusb
’s output to dynamically get the bus and port number of a specific device every time the script is called, this would allow you to use any USB port, but I feel that would be an overkill here.Suggestions taken from this linux.com blog article.