Last active
August 2, 2024 16:17
-
-
Save jdtimmerman/e2da93eaf751a6d1dd73fb683ad8767f to your computer and use it in GitHub Desktop.
Run powertop --auto-tune but exclude some devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Script for running powertop --auto-tune but disable optimizations for some devices | |
# | |
# Based on solution from https://askubuntu.com/a/1026527/53903 | |
powertop --auto-tune | |
devices=( | |
"0001:abcd" # My important device | |
"1234:cdef" # More devices | |
# ... | |
) | |
find_by_id(){ | |
VENDOR="${1%:*}" | |
PRODUCT="${1#*:}" | |
find -L /sys/bus/usb/devices/ -maxdepth 2 -type f -name "idVendor" -exec dirname "{}" \; | while read SYS_DIR; do | |
if [ $VENDOR == "$(cat $SYS_DIR/idVendor)" ] && [ $PRODUCT == "$(cat $SYS_DIR/idProduct)" ]; then | |
echo $SYS_DIR | |
fi | |
done | |
} | |
echo "Keeping the following devices enabled:" | |
for d in ${devices[@]}; do | |
DEVICE=$(find_by_id $d) | |
echo "- $(cat "$DEVICE/product") [$(cat "$DEVICE/manufacturer")]" | |
echo "on" > "$DEVICE/power/control"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment