unixorn/tumult.plugin.zsh

View on GitHub
bin/fix-airplay

Summary

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

set -o pipefail

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

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

# shellcheck disable=SC2009
exec kill "$(ps -ax | grep '/usr/sbin/coreaudiod' | awk '{print $1}')"