diff --git a/src/connector.sh b/src/connector.sh index f902fd0..8543c85 100644 --- a/src/connector.sh +++ b/src/connector.sh @@ -1,7 +1,7 @@ SYSTEM_PROFILER=$(system_profiler SPBluetoothDataType 2>/dev/null) -MAC_ADDRESS=$(grep -B8 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/Address/{ print $2 }') -CONNECTED=$(grep -A6 "${MAC_ADDRESS}" <<< "${SYSTEM_PROFILER}" | awk '/Connected: Yes/{ print 1 }') +MAC_ADDRESS=$(grep -B8 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/Address/{print $2}') +CONNECTED=$(grep -A10 "${MAC_ADDRESS}" <<< "${SYSTEM_PROFILER}" | awk '/Services:/{print 1}') NAME=$(grep -B9 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/AirPods/{ print }' | sed -e 's/^ *//' -e 's/://') if [[ "${CONNECTED}" ]]; then