Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 35 lines (28 sloc) 1.584 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/bin/sh

# OK so this even exists because after suspending my Dell Vostro 3350
# without headphones plugged in they won't work after resuming from it.
# Same goes for speakers at suspend with headphones plugged.
#
# So how this script works?
# - Stop any player that might be using sound output right.
# - Plug or unplug your headphones depending on what output you want to get
# working and run this script.
#
# *Must be run as root*

BATSTAT="`cat /sys/class/power_supply/AC/online`"

if test $BATSTAT -gt 0
then
    echo "1" | tee "/sys/module/snd_hda_intel/parameters/power_save" &>/dev/null
    echo "Y" | tee "/sys/module/snd_hda_intel/parameters/power_save_controller" &>/dev/null
    echo "1" | tee "/sys/module/snd_ac97_codec/parameters/power_save" &>/dev/null


    echo "0" | tee "/sys/module/snd_hda_intel/parameters/power_save" &>/dev/null
    echo "N" | tee "/sys/module/snd_hda_intel/parameters/power_save_controller" &>/dev/null
    echo "0" | tee "/sys/module/snd_ac97_codec/parameters/power_save" &>/dev/null

else
    echo "0" | tee "/sys/module/snd_hda_intel/parameters/power_save" &>/dev/null
    echo "N" | tee "/sys/module/snd_hda_intel/parameters/power_save_controller" &>/dev/null
    echo "0" | tee "/sys/module/snd_ac97_codec/parameters/power_save" &>/dev/null

    echo "1" | tee "/sys/module/snd_hda_intel/parameters/power_save" &>/dev/null
    echo "Y" | tee "/sys/module/snd_hda_intel/parameters/power_save_controller" &>/dev/null
    echo "1" | tee "/sys/module/snd_ac97_codec/parameters/power_save" &>/dev/null
fi
Something went wrong with that request. Please try again.