Skip to content

Commit

Permalink
update script, differentiate Apple silicon from Intel
Browse files Browse the repository at this point in the history
  • Loading branch information
godbout committed Jul 23, 2023
1 parent 1fce9d9 commit d87340b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Binary file added Sources/scripts/.DS_Store
Binary file not shown.
12 changes: 9 additions & 3 deletions Sources/scripts/connector.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
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 -A10 "${MAC_ADDRESS}" <<< "${SYSTEM_PROFILER}" | awk '/Services:/{print 1}')

if [[ $(arch) == 'arm64' ]]; then
CONNECTED=$(resources/binaries/blueutil_arm64 --is-connected ${MAC_ADDRESS})
else
CONNECTED=$(resources/binaries/blueutil_i386 --is-connected ${MAC_ADDRESS})
fi

NAME=$(grep -B9 "Minor Type: Headphones" <<< "${SYSTEM_PROFILER}" | awk '/AirPods/{ print }' | sed -e 's/^ *//' -e 's/://')

if [[ "${CONNECTED}" ]]; then
if [[ "${CONNECTED}" == 1 ]]; then
status="disconnect ${NAME}"
# disconnect doesn't work on Monterey if we don't force notify LMAO
arg="--disconnect ${MAC_ADDRESS//:/-} --notify"
arg="--disconnect ${MAC_ADDRESS//:/-}"
else
status="connect ${NAME}"
arg="--connect ${MAC_ADDRESS//:/-}"
Expand Down
Binary file modified Workflow/.DS_Store
Binary file not shown.

0 comments on commit d87340b

Please sign in to comment.