How do I detect if headphones are connected (via the jack) in bash?
I found an answer from here:
if system_profiler SPAudioDataType | grep --quiet Headphones; then
  echo plugged in
else
  echo not plugged in
fi