For that very reason I activate the powertop service in Fedora 41:
sudo systemctl --now enable powertop
That runs a “powertop --auto-tune” at boot up time. It’s not perfect, sometimes I see a lot of the PM runtime ones are still “Bad”, and powertop 2.15.9 has a bug I wrote up about it turning optical mice off.
My bug in bugzilla,
https://bugzilla.redhat.com/show_bug.cgi?id=2300988
related upstream bug,
It’s in ASSIGNED mode still on that bug. I work around that by having a drop-in added to my powertop service so it runs a script I wrote.
#!/bin/bash
# /usr/local/bin/powertop-mouse.sh
# powertop-mouse.sh -- tries to deal with the mouse fix on different ports
# related to systemd powertop service
for pf in /sys/bus/usb/devices/?-?/product
do
# this might not be portable to all mouses, maybe some don't result in a "product" file?, but the one I have
# matching $pf/../power/control to 'on'
# At the worst, this would just not set the control to 'on'
if grep -qi mouse $pf; then
parent="$(dirname $pf)"
#echo "$parent points to a mouse"
#cat $pf
if [[ $(id -u) -gt 0 ]]; then
# ordinary user running it would just see the dryrun to see where
# the mouse is
echo "$0 DRYRUN set 'on' for mouse in $parent/power/control"
else
echo "$0 set 'on' for mouse in $parent/power/control"
echo "on" > $parent/power/control
fi
exit 0
fi
done
exit 1
It’s complicated because I wanted the mouse not being turned off to work for any USB port. If you always have it on the same port, the script isn’t needed and you can do it all in the systemd drop-in file at /etc/systemd/system/powertop.service.d/override.conf. The below shows the “one-line, no script” way commented in and the script commented out assuming the mouse is on USB “1-1”
cat /etc/systemd/system/powertop.service.d/override.conf
[Unit]
Wants=tuned.target
After=tuned.target
[Service]
ExecStartPost=bash -c 'echo "on" > /sys/bus/usb/devices/1-1/power/control'
#ExecStartPost=/usr/local/bin/powertop-mouse.sh