Skip to content

Commit

Permalink
Picking up the AirPod name dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
davosian committed Dec 13, 2021
1 parent e1541fe commit 73bbc4f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SYSTEM_PROFILER=$(system_profiler SPBluetoothDataType 2>/dev/null)

MAC_ADDRESS=$(grep -B8 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/Address/{ lastline = $2 } END { print lastline }')
CONNECTED=$(grep -A6 "${MAC_ADDRESS}" <<< "${SYSTEM_PROFILER}" | awk '/Connected: Yes/{ print 1 }')
NAME=$(grep -B9 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/AirPods/{ print }' | sed -e 's/^ *//' -e 's/://')
NAME=$(grep -B9 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/^[ ]{10}([A-Za-z]+)/{ lastline = $1 } END { print lastline }' | sed -e 's/://')

if [[ "${CONNECTED}" ]]; then
status="disconnect ${NAME}"
Expand Down

0 comments on commit 73bbc4f

Please sign in to comment.