Contribute
Register

No OnBoard Audio After Wake From Sleep?

Status
Not open for further replies.
This worked great for me, finally fixed my no audio after sleep problems! :headbang:
 
The script is very simple: create /Library/Scripts/HDAreload.sh (or whatever you would like to call it) with this code:
Code:
#!/bin/bash
[FONT=Verdana]kextunload /System/Library/Extensions/AppleHDA.kext
kextload /System/Library/Extensions/AppleHDA.kext
kextload /System/Library/Extensions/AppleHDA.kext    # not sure why this is here twice, but  that's how it was in the original. Maybe a pause is needed instead?[/FONT][FONT=Verdana]
[/FONT]exit 0

Now create the file /System/Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.plist as follows:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>de.bernhard-baehr.sleepwatcher</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/sbin/sleepwatcher</string> <!-- path to exec -->
        <string>-w /Scripts/Library/HDAreload.sh</string> <!-- your script path -->
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>UserName</key>
    <string>root</string>  <!-- allows file to run w/o needing admin pw -->
</dict>
</plist>

Hello All,

I just installed sleepwatcher deamon and created the two above mentioned files (with sudo vi) and it works on my El Capitan hackintosh.

I built a GA-Z77N-Wifi + i5-3570K Mountain Lion Hackintosh in May 2013, then updated it to Mavericks in 2014. I recently updated it directly to El Capitan, with a fresh build followed by an import of older system (and then removing unneeded kexts from /System/Library/Extensions, especially FakeSMC.kext).
Everything was neat apart from the sound not working after sleep/wake.

Thank you randombrain and all! :)
 
ACTUALLY I think I may have a near-perfect solution. It requires a bit of setup, but should work noiselessly in the background forever after. (Full disclosure: I haven't tested this on my Hackintosh yet. However, it's based entirely on a working setup I have for something else.) EDIT: Works exactly as expected on my Hackintosh. Machine wakes from sleep, sound doesn't work for a second or two, sound starts working again. No password input needed.

What we're going to do is turn shilohh's AppleScript code (which is just a wrapper for some BASH commands anyway) into a BASH script, then make a launch daemon that runs this script every time the machine wakes.

The script is very simple: create /Library/Scripts/HDAreload.sh (or whatever you would like to call it) with this code:
Code:
#!/bin/bash
[FONT=Verdana]kextunload /System/Library/Extensions/AppleHDA.kext
kextload /System/Library/Extensions/AppleHDA.kext
kextload /System/Library/Extensions/AppleHDA.kext    # not sure why this is here twice, but  that's how it was in the original. Maybe a pause is needed instead?[/FONT][FONT=Verdana]
[/FONT]exit 0

Now we need to set up the daemon. This is accomplished with a separate function, Bernhard Baehr's sleepwatcher. Download from his website and install as described in the readme. (He wants you to install to /usr/local/sbin, but I just put it in /usr/bin like I usually do. Not sure if that's best-practice or not.) Now create the file /System/Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.plist as follows:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>de.bernhard-baehr.sleepwatcher</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/sbin/sleepwatcher</string> <!-- path to exec -->
        <string>-w /Scripts/Library/HDAreload.sh</string> <!-- your script path -->
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>UserName</key>
    <string>root</string>  <!-- allows file to run w/o needing admin pw -->
</dict>
</plist>

Almost done—just run
Code:
sudo launchctl load -wF /System/Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.plist
in Terminal and you should be good!

I tried to make both scripts using sudo vi. I was able to make them and put them in their proper locations. I also was able to install sleepwatcher and run the sudo launchctl command but it doesn't seem to be working. Could there perhaps be an execution permissions issue that launchctl cannot run the HDAreload.sh? Or could there perhaps be a log I can reference to see what is the exact issue? I'm assuming its something really simple that I cannot figure out.

Thanks in advanced!
 
Status
Not open for further replies.
Back
Top