Why my USB mouse gets suspended after 3 seconds of inactivity?

77

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.

Share:
77

Related videos on Youtube

Izzy
Author by

Izzy

Updated on September 18, 2022

Comments

  • Izzy
    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 and Unique 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.
      Vi. about 12 years
      I have just observed it. May be reboot will fix it, but I want to know why this can happen.
    • Emanuel Landeholm
      Emanuel Landeholm over 9 years
      My 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
      AnthonyLambert over 7 years
      Path.GetFullPath(fileName) returns the full path not the filename.
    • Izzy
      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
      juharr over 7 years
      You 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
      juharr over 7 years
      Your method has an argument called uniqueNumber, but you use something called rmaNumber 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
      Izzy over 7 years
      @juharr Sorry that was a typo from when I was trying out a different param.
    • TripleEEE
      TripleEEE over 7 years
      Path.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
      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
      C.Evenhuis over 7 years
      You really should be able to pin the problem down to the individual part(s) that go into the string.Concat yourself...
    • juharr
      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
      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
    Renan about 12 years
    He doesn't says if it's a wireless mouse.
  • Vi.
    Vi. about 12 years
    This is wired USB mouse.
  • siesta
    siesta about 12 years
    Ok. 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.
    Vi. about 12 years
    The LED is not dimmed, but is off at all, preventing the normal use of mouse (need to click every time before moving).
  • Vi.
    Vi. about 12 years
    Battery saving? Probably, because of turning the netbook to AC prevents turning off mouse. How to [temporarily] disable such energy saving?
  • siesta
    siesta about 12 years
    firstly try "sudo pm-powersave false" if not work search for "laptop-mode-tools"
  • Vi.
    Vi. about 12 years
    "pm-powersave false" does nothing, but disabling laptop-mode-tools works.
  • BrunoJCM
    BrunoJCM almost 11 years
    Man, you really said something that makes sense. Thanks!
  • BrunoJCM
    BrunoJCM almost 11 years
    I 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
    Sharuzzaman Ahmat Raslan over 8 years
    This answer solved my problem in Debian. I blacklisted usbhid and psmouse and after restarting laptop-mode service, and replug my mouse, the issue is solved
  • lepe
    lepe over 7 years
    only the first command (for ...) did work. I tried everything even stopping laptop-mode service and it didn't change. Thanks
  • Izzy
    Izzy over 7 years
    I've just tried this and it works perfectly! Thank you. just a quick note I updated this line .Replace(".", " ") to .Replace("/", " ")
  • Martin Pecka
    Martin Pecka about 7 years
    This 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
    OscarGarcia about 7 years
    Because of that I suggest AUTOSUSPEND_USBID_BLACKLIST too.
  • Thomas
    Thomas about 6 years
    Doesn't work for me on Ubuntu 14.04, lenovo thinkpad :(
  • OscarGarcia
    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
    Simon Baars almost 6 years
    The file /etc/laptop-mode/conf.d/usb-autosuspend.conf doesn't exist for me. Should I create it?