#!/usr/bin/env bash
#
# Airplay sometimes craps out, add helper to kick it
#
# Copyright 2016, Joe Block <jpb@unixorn.net>

set -o pipefail

if [[ "$(whoami)" != "root" ]]; then
  echo "This script must be run by root or with sudo"
  exit 1
fi

if [ $(uname -a | grep -ci Darwin) != 1 ]; then
  echo "Sorry, this script only works on macOS"
  exit 1
fi

kill $(ps -ax | grep '/usr/sbin/coreaudiod' | awk '{print $1}')
