diff --git a/native/installer/postinstall.sh b/native/installer/postinstall.sh index 2901919..5bddca2 100644 --- a/native/installer/postinstall.sh +++ b/native/installer/postinstall.sh @@ -4,89 +4,96 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURRENT_DRIVER_VERSION=$(defaults read /Library/Audio/Plug-Ins/HAL/eqMac.driver/Contents/Info CFBundleVersion) -NEEDED_DRIVER_VERSION=$(defaults read $DIR/eqMac.driver/Contents/Info CFBundleVersion) +LATEST_DRIVER_VERSION=$(defaults read $DIR/eqMac.driver/Contents/Info CFBundleVersion) echo $CURRENT_DRIVER_VERSION -echo $NEEDED_DRIVER_VERSION +echo $LATEST_DRIVER_VERSION -if [ "$CURRENT_DRIVER_VERSION" != "$NEEDED_DRIVER_VERSION" ]; then +restart_mac () { + osascript </dev/null - if osascript </dev/null || \ + launchctl kill SIGTERM system/com.apple.audio.coreaudiod &>/dev/null || \ + launchctl kill TERM system/com.apple.audio.coreaudiod &>/dev/null || \ + launchctl kill 15 system/com.apple.audio.coreaudiod &>/dev/null || \ + launchctl kill -15 system/com.apple.audio.coreaudiod &>/dev/null || \ + (launchctl unload "$coreaudiod_plist" &>/dev/null && \ + launchctl load "$coreaudiod_plist" &>/dev/null) || \ + killall coreaudiod &>/dev/null) + + # Wait until CoreAudio restarts + sleep 5 + + # Wait until coreaudiod has restarted and device is ready to use. + retries=5 + while [[ $retries -gt 0 ]]; do + if ! system_profiler SPAudioDataType | grep "eqMac:" >/dev/null 2>&1; then + retries=$((retries - 1)) + if [[ $retries -gt 0 ]]; then + echo "Device not ready yet, waiting..." + sleep 3 + else + if osascript </dev/null || \ - launchctl kill SIGTERM system/com.apple.audio.coreaudiod &>/dev/null || \ - launchctl kill TERM system/com.apple.audio.coreaudiod &>/dev/null || \ - launchctl kill 15 system/com.apple.audio.coreaudiod &>/dev/null || \ - launchctl kill -15 system/com.apple.audio.coreaudiod &>/dev/null || \ - (launchctl unload "$coreaudiod_plist" &>/dev/null && \ - launchctl load "$coreaudiod_plist" &>/dev/null) || \ - killall coreaudiod &>/dev/null) - - # Wait until CoreAudio restarts - sleep 5 - - # Wait until coreaudiod has restarted and device is ready to use. - retries=5 - while [[ $retries -gt 0 ]]; do - if ! system_profiler SPAudioDataType | grep "eqMac:" >/dev/null 2>&1; then - retries=$((retries - 1)) - if [[ $retries -gt 0 ]]; then - echo "Device not ready yet, waiting..." - sleep 3 - else - if osascript <