Alert sound not playing when logged in as other user.
  • I have a separate admin account called "maint" which automatically logs in at startup just to run SecuritySpy. When I'm logged in to that account (in the GUI) my alert script runs when triggered and I can hear the alert sound on the computer. However when I switch users and log in as myself in the GUI, the sound doesn't play. The Applescript that runs is simply:

    ```
    do shell script "bash /Users/maint/SecuritySpy/Scripts/motion_action.sh"
    ```
    The shell script is this:
    ```
    #!/bin/bash
    # motion_action.sh
    sound="/Users/maint/Library/Sounds/dogs.mp3"
    afplay /System/Library/Sounds/Blow.aiff && afplay /System/Library/Sounds/Blow.aiff && afplay $sound
    ssh other_machine /usr/bin/open /Users/chetstone/SecuritySpy/Scripts/PauseAlert.app
    ```
    I know the script runs when triggered because the ssh command works to play the sound on the other_machine in another room, but I can't hear anything on my computer. And when I run the script in Terminal when logged into a shell either as myself or the "maint" user I can hear the sound (when logged in as myself in the GUI). I can even ssh in to "maint" from another machine and it works.

    I suspect there's an environment variable that's there (or isn't there and should be) when the script is run by SecuritySpy via applescript that prevents sound from playing when the owner of the process is not logged into the GUI. Odd that this is bypassed when running the script in terminal though.

    Does anyone have any hints on what is happening and how to work around it?

    thanks
  • I haven't come across this before, but it must be macOS preventing (at least some) sounds from background user accounts.

    Have you tried adding the sound to SecuritySpy's Sounds folder (~/SecuritySpy/Sounds/) and then getting SecuritySpy to play the sound as an Action, under Preferences -> Cameras -> Actions?
  • Yes, doing the same thing happens when using one of SecuritySpy's built in sounds.
  • How about using the method you are already using to play the sound on the other Mac, but apply it to the primary Mac too? So turn on Remote Login in the Sharing system prefs, and use ssh user@localhost to send commands back to itself. I presume you're using keys for the SSH authentication? Just do the same thing as you did for the other machine.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!