Skip to content

Instantly share code, notes, and snippets.

@oddbjornkvalsund
Created March 25, 2019 11:47
Show Gist options
  • Save oddbjornkvalsund/21ad3b6ca2ea53ef0580f712a6058fc9 to your computer and use it in GitHub Desktop.
Save oddbjornkvalsund/21ad3b6ca2ea53ef0580f712a6058fc9 to your computer and use it in GitHub Desktop.
# Powertop auto-tune
cat > /usr/local/bin/powerkeepalive << EOF
#!/bin/bash
for usbdevice in \$(find /sys/bus/usb/devices/); do test -w \${usbdevice}/power/control && echo on > \${usbdevice}/power/control; true; done
echo 0 > /sys/module/snd_hda_intel/parameters/power_save
EOF
chmod +x /usr/local/bin/powerkeepalive
# TODO after calling usbkeepalive, just get rid of audio static/noise:
# https://osxlatitude.com/forums/topic/11316-how-to-fix-static-noisedistortioncrackling-sound-and-combojack-in-laptops/
# Also: hda-verb /dev/snd/hwC0D0 0x18 SET_PIN_WIDGET_CONTROL 0x20
# To test: reboot and play Sigur Ros, first track on Hlemmur:
# https://play.google.com/music/listen?u=1#/album/Bt2wswy5kwqn7onhmrah3t4dkmu
# HDA maintainer: https://bugzilla.redhat.com/show_bug.cgi?id=1660581
add_line "options snd-hda-intel position_fix=1" /etc/modprobe.d/alsa-base.conf
test -f /etc/systemd/system/powertop-autotune.service || cat >> /etc/systemd/system/powertop-autotune.service << EOF
[Unit]
Description=Auto-tune power savings (oneshot)
[Service]
Type=oneshot
ExecStart=/usr/sbin/powertop --auto-tune
ExecStartPost=/usr/local/bin/powerkeepalive
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
EOF
systemctl enable powertop-autotune
systemctl start powertop-autotune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment