9

I like powertop --auto-tune because the speakers of my laptop are soughing when not being used and powertop disables the speakers completely when they're not used, stopping the noise.

However, my USB mouse gets disabled within seconds after not using it and after a few more seconds, my touchpad has a delayed response (works fine after the first delay of a fraction of a second, though).

How do I make this stop but still disable my speakers completely when no audio is put out?

UTF-8
  • 5,710
  • 10
  • 31
  • 67

3 Answers3

20

If you run powertop --auto-tune manually you could create a script like:

cat - > powertune.sh <<EOF
#!/bin/bash
powertop --auto-tune
HIDDEVICES=$(ls /sys/bus/usb/drivers/usbhid | grep -oE '^[0-9]+-[0-9\.]+' | sort -u)
for i in $HIDDEVICES; do
  echo -n "Enabling " | cat - /sys/bus/usb/devices/$i/product
  echo 'on' > /sys/bus/usb/devices/$i/power/control
done
EOF

The script will run powertop and then look at all the USB devices using the Human Interface Device driver and subsequently disable power management for them. So it should be resistant to plugging mice/keyboard in different ports.

You could also combine it with a systemd service to run it automatically at bootup.

  • 1
    Excellent, thank you. The only thing is that cat here would not produce the expected result, because it will substitute the values of HID devices that are currently in use, hardcoding them. To preserve the dynamic device selection, just copy-paste the contents of the heredoc (the part between EOF) into a file manually. – Ivan Aksamentov - Drop Apr 30 '18 at 17:34
  • This is great (although I copied the script, rather than use cat EOF. I think it's best to simplify the answer in that sense. The logic is solid though, finally no more issues with powertop! :) – WhyNotHugo Apr 13 '20 at 12:23
  • I've made a variant to this solution which takes a number of device-id's to exclude https://gist.github.com/jdtimmerman/e2da93eaf751a6d1dd73fb683ad8767f – Joost Nov 09 '22 at 23:21
  • suggested fix: changing <<EOF to <<'EOF' fixes the problem – Lari Hotari Sep 14 '23 at 06:44
10

Try running "sudo powertop" and tab over to the "Tunables" selection, there it should show you a list of everything that powertop is able to tune. Somewhere on that list will show your something like, "Autosuspend for USB device...,"

One of the USB devices listed should be the one you are having trouble with; try leaving it's settings as "Bad" as that is the unmodified state.

Check out the powertop users guide for additional info and tips: https://01.org/sites/default/files/page/powertop_users_guide_201406.pdf

RDK
  • 116
  • 2
    Thank you! Is there a command disabling power saving for this specific device? Doing this every time I restart my laptop is inconvenient. If this isn't possible: Is there a command to enable power saving only for one specific device? I don't really need powertop --auto-tune but instead only care that a single device is on power save mode (and that my mouse isn't). – UTF-8 Dec 15 '15 at 19:45
  • 1
    Thank you! Thanks to you I found out that powertop shows what line it's running to set a certain power setting right when this is done manually. This solved my problem. :) – UTF-8 Dec 18 '15 at 03:14
4

Check out my little project to create a shell script to automatically apply powertop's "good" power settings.

You can then easily edit the resulting script to comment out any configuration that's giving you trouble and run it instead of sudo powertop --auto-tune.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Jesse
  • 41