Why my USB mouse gets suspended after 3 seconds of inactivity?
Solution 1
It's a very old question, related with laptop-mode, but I'll post my solution:
In Ubuntu 14.04 I edited /etc/laptop-mode/conf.d/usb-autosuspend.conf
and change this lines to blacklist usbhid
:
# The list of USB driver types that should not use autosuspend. The driver
# type is given by "DRIVER=..." in a USB device's uevent file.
# Example: AUTOSUSPEND_USBID_BLACKLIST="usbhid usb-storage"
## Old value: AUTOSUSPEND_USBTYPE_BLACKLIST=""
AUTOSUSPEND_USBTYPE_BLACKLIST="usbhid"
In Ubuntu 12.04 I must to edit /etc/laptop-mode/conf.d/runtime-pm.conf
and change this lines to blacklist usbhid
:
# The list of device driver types that should use autosuspend. The driver
# type is given by "DRIVER=..." in a device's uevent file.
# Example: AUTOSUSPEND_DEVTYPE_WHITELIST="usbhid usb-storage"
## Old value: AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST=""
AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST="usbhid"
You can also blacklist usb-storage
! and you can also blacklist device by ID (AUTOSUSPEND_RUNTIME_DEVID_WHITELIST
in Ubuntu 12.04 or AUTOSUSPEND_USBID_BLACKLIST
in Ubuntu 14.04).
Then you'll need to restart laptop mode for the changes to take effect:
sudo /etc/init.d/laptop-mode restart
And then replug mouse. The mouse will not suspend again.
This works for me at work (ubuntu 12.04) and home (ubuntu 14.04).
Hope It helps :)
Solution 2
I have the perfect solution!
If
for i in /sys/bus/usb/devices/*/power/control; do echo on > $i; done
works for you, but only once, edit /etc/laptop-mode/conf.d/usb-autosuspend.conf
to replace :
CONTROL_USB_AUTOSUSPEND="auto"
by
CONTROL_USB_AUTOSUSPEND=0
It works for me.
Related videos on Youtube
Izzy
Updated on September 18, 2022Comments
-
Izzy over 1 year
I'm currently trying to add a
DateTime
stamp, a prefix and a unique number to a file name. My desired output is:\ParentDirectory\Sub Directory\Another Sub Directory\Prefix- Unique Number - 11 29 2016 2 07 30 PM.xlsx
Prefix
andUnique Number
above will be passed into the function. I'm using the following method to achieve this:public static string AppendDateTimeToFileName(this string fileName, string prefix, string uniqueNumber) { return string.Concat( Path.GetFullPath(fileName), Path.Combine(prefix + " - " + uniqueNumber + " - "), Path.GetFileNameWithoutExtension(fileName), DateTime.Now.ToString() .Replace("/", " ") .Replace(":", " ") .Trim(), Path.GetExtension(fileName) ); }
I call the above method as:
string fileName = @"\\ParentDirectory\Sub Directory\Another Sub Directory\MyFile.xlsx"; string adjustedFileName = fileName.AppendDateTimeToFileName("Shipping Note", "0254900");
The output I receive is as follows:
\ParentDirectory\Sub Directory\Another Sub Directory\Shipping Note -\0254900 - 11 29 2016 2 08 10 PM
As you can see in the above output the string is incorrect, firstly I get an extra
-\
and the file extension isn't coming through either. Can someone tell me where I'm going wrong please.-
Vi. about 12 yearsI have just observed it. May be reboot will fix it, but I want to know why this can happen.
-
Emanuel Landeholm over 9 yearsMy crappy no name wireless mouse does this. It doesn't matter if my computer is plugged in or on battery. To make matters worse, no amount of activity will "unsuspend" the mouse once it gets stuck, forcing me to remove and reinsert the batteries every 3-5 seconds. Useless piece of s**t.
-
AnthonyLambert over 7 yearsPath.GetFullPath(fileName) returns the full path not the filename.
-
Izzy over 7 years@AnthonyLambert oh ok, but how comes I get an extra `-` in my returned value? Also I want to return the full path along with the appended file because later on I save the file to the path with the new name
-
juharr over 7 yearsYou don't need
Path.Combine
just to concatenate the prefix and number together.Path.Combine
is for combining parts of a path with the appropriate path separator. -
juharr over 7 yearsYour method has an argument called
uniqueNumber
, but you use something calledrmaNumber
instead. When I fix that my result is "\\ParentDirectory\Sub Directory\Another Sub Directory\MyFile.xlsxShipping Note - 0254900 - MyFile11 29 2016 9 38 04 AM.xlsx" -
Izzy over 7 years@juharr Sorry that was a typo from when I was trying out a different param.
-
TripleEEE over 7 yearsPath.Combine(prefix + " - " + rmaNumber + " - "), I think because you have the
-
there? You ` \ ` : Here is your answer: It is not realy a \ which is added but a null character stackoverflow.com/questions/2292850/… -
Izzy over 7 years@juharr How come
MyFile.xlsx
isn't being appended? It'll work if it's just the file name but I need to return the entire directory path with it too -
C.Evenhuis over 7 yearsYou really should be able to pin the problem down to the individual part(s) that go into the
string.Concat
yourself... -
juharr over 7 years@Code Not sure why you got a result that was different, but as Anthony said
GetFullPath
will include the file name. -
Martin Pecka about 7 years@Vi.: I propose changing the accepted answer to the one of OscarGarcia, because his is the most accurate, actually answers both your questions, and doesn't have any side-effects like disabling USB autosuspend at all...
-
-
Renan about 12 yearsHe doesn't says if it's a wireless mouse.
-
Vi. about 12 yearsThis is wired USB mouse.
-
siesta about 12 yearsOk. I just looked my wired usb mouse and also it is getting inactive after 5 seconds, and this is also for energy saving, because you may use it with a laptop which battery time matters. And isn't it a good feature?
-
Vi. about 12 yearsThe LED is not dimmed, but is off at all, preventing the normal use of mouse (need to click every time before moving).
-
Vi. about 12 yearsBattery saving? Probably, because of turning the netbook to AC prevents turning off mouse. How to [temporarily] disable such energy saving?
-
siesta about 12 yearsfirstly try "sudo pm-powersave false" if not work search for "laptop-mode-tools"
-
Vi. about 12 years"pm-powersave false" does nothing, but disabling laptop-mode-tools works.
-
BrunoJCM almost 11 yearsMan, you really said something that makes sense. Thanks!
-
BrunoJCM almost 11 yearsI didn't know that I had the 'laptop-mode-tools' package installed.. It may also explain other problems with the cpu scalling indicator I had.
-
Sharuzzaman Ahmat Raslan over 8 yearsThis answer solved my problem in Debian. I blacklisted
usbhid
andpsmouse
and after restartinglaptop-mode
service, and replug my mouse, the issue is solved -
lepe over 7 yearsonly the first command (for ...) did work. I tried everything even stopping laptop-mode service and it didn't change. Thanks
-
Izzy over 7 yearsI've just tried this and it works perfectly! Thank you. just a quick note I updated this line
.Replace(".", " ")
to.Replace("/", " ")
-
Martin Pecka about 7 yearsThis should really be the accepted answer, since it only blacklists autosuspend of HID devices, but leaves you the possibility to autosuspend all other devices.
-
OscarGarcia about 7 yearsBecause of that I suggest
AUTOSUSPEND_USBID_BLACKLIST
too. -
Thomas about 6 yearsDoesn't work for me on Ubuntu 14.04, lenovo thinkpad :(
-
OscarGarcia about 6 years@Thomas which of the solutions does not work for you? Could you share the lsusb id or the module, mouse type, ect? If it is using an wireless adaptor, maybe it is necessary to blacklist it too! Edit: do you have
laptop-tools
installed? -
Simon Baars almost 6 yearsThe file
/etc/laptop-mode/conf.d/usb-autosuspend.conf
doesn't exist for me. Should I create it?