HDMI audio prevents screen saver

Is there a long German word for: "You Google a problem, and the only results are you asking about it the last time you ran into it"?

Because that happens to me a lot.

Anyway, MacOS 10.11 still has the ridiculous bug that if your system audio output is set to HDMI, and iTunes is playing, then the screen saver will never activate and your screen will never lock. I fixed this once before, but the procedure has gotten more complicated because now certain system files can't be modified even by root. So now the new recipe is:

  1. Gently apply the Stick of Correction to a copy of the binary:

    sudo -s
    mkdir -p /usr/local/sbin
    cp -p /usr/sbin/coreaudiod \
          /usr/local/sbin/coreaudiod.hacked
    perl -pi \
      -e 's/N(oDisplaySleepAssertion)/_$1/g;' \
      -e 's/P(reventUserIdleDisplaySleep)/_$1/g;' \
      /usr/local/sbin/coreaudiod.hacked
    codesign -vfs 'Your Name' \
      /usr/local/sbin/coreaudiod.hacked

  2. Boot in "Recovery Mode" (Cmd-R), and in "Utilities / Terminal", type:

    csrutil disable

  3. Boot in "Standalone Mode" (Cmd-S), and type:

    mount -uw /
    rm /usr/sbin/coreaudiod
    ln -s /usr/local/sbin/coreaudiod.hacked \
          /usr/sbin/coreaudiod

  4. Boot in "Recovery Mode" (Cmd-R), and in "Utilities / Terminal", undo what you did the first time:

    csrutil enable

  5. Third reboot, and you're done. EASY.


Update: It turns out that upgrading to 10.11.2 blows away that coreaudiod symlink. Since I don't want to have to reboot three times every time I do a point-release update of the OS, here's a way to fix coreaudiod that does not necessitate rebooting.

  1. Step 1 is the same as above.

  2. Create a new plist file:

    sed 's@/usr/sbin/coreaudiod@/usr/local/sbin/coreaudiod.hacked@g' < /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist > /usr/local/etc/com.apple.audio.coreaudiod.plist

    chmod og-w /usr/local/etc/com.apple.audio.coreaudiod.plist

  3. Kill the old coreaudiod and launch the new one:

    launchctl unload /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist

    launchctl load -w /usr/local/etc/com.apple.audio.coreaudiod.plist

  4. Restart iTunes, or whatever was making noise and now isn't.

Previously.

Tags: , , ,

19 Responses:

  1. jwz says:

    Oh, and if step 2 tells you that you don't have csrutil then that's probably because you upgraded to 10.11 from a previous release instead of doing a fresh install, an your recovery partition is out of date. Rebuild it using Partition Creator. Version 3.8 works on 10.11 even though it hasn't been updated since 10.9.

    • Ryan Finnie says:

      Interestingly, csrutil worked for me even though the box in question has been upgraded multiple times. I know this because I lasted about 5 minutes before finding root is no longer root (can't remember what I was doing, but I seem to remember it was something I was doing, not a misbehaving app), said "yeah, no" and looked how to disable it.

    • ssl-3 says:

      Jesus god.

      With this level of fragmentation, does it surprise anyone that my go-to *nix box these days is a low-power 32-bit MIPS wireless router?

  2. emacsomancer says:

    Oddly enough this is a bug I'm trying to implement on Linux (namely don't sleep/screensaver if there is audio playing), as a workaround for preventing sleep/suspend/screensaver when watching films/youtube.

    • anonnymoose says:

      I assume you're blocked on the "prevent the system from sleeping/hibernating" part of the task, and not the "prevent the screen from blanking" part? If not, read on:

      Does running 'xset -dpms' prevent screen power down and 'xset s off' prevent screensaver activation on your system? If it does, until browsers implement the hooks to prevent the screen from sleeping [0], you could assign a key combo to run a script that runs those commands on demand.

      [0] This is a thing that's in the works, but AFAIK, not done yet.

      • jwz says:

        You people. It's not like there's an xscreensaver FAQ or manual or anything.

      • emacsomancer says:

        Yeah, it's really the sleeping/hibernating part.

        I don't really want to have to do something beforehand, like turn on Caffeine or press a key combo. I just want it to work. In part, because I'm not the primary user of the machine in question.

    • Mjog says:

      I guess "Just run Gnome", because it has already been fixed there isn't a solution?

      /me ducks

      • emacsomancer says:

        I didn't know that it had been fixed in Gnome (like, really fixed?)

        However, though I've tried a couple of times, Gnome isn't very useable, at least for me and mine.

  3. Lloyd says:

    The behaviour makes sense across a wide range of Apple devices.

    For example, on AppleTV you don't want to lock the screen because there's no keyboard to unlock it with.

    Ditto for Apple Watch.

    • jwz says:

      That's a fascinating observation, about two devices with completely different operating systems, use cases and and hardware interfaces. One of which doesn't have a screen locker at all.

      So yeah, thanks for your insight.

  4. Lloyd says:

    That's the well-known googleschonwiederererneutesuchebereitsgesehenaufwärmendverhandlung.

  5. mb says:

    It's French, but I think "deja vu" is close to what you're looking for.

  6. Ben says:

    Something, something don't want to sysadmin my home PC...

    (I say this as someone who was motivated by you to stop futzing with Linux at home and get a Mac - I get paid to futz with Linux, don't need to do that on my own time).

  7. Mark says:

    Wiedergoogelneinsamkeitsverzweiflung: The despair of one's isolation in Googling something again.

  8. Monkey Mind says:

    HimmlherrgottsakramentkreizkruzifixhallelujalecksmiamoarschscheissGUUGLverreckts!

  9. Craniac says:

    schmerzhafte Rekursivit├Ąt?

  10. kstop says:

    I nominate Suchezwang.