Adding Battery Level of 3rd Party Earphones

Hi,

Is there any way to add the battery level of 3rd party earphones (besides AirPods & Beats) in the connectivity actions? If I were to modify from the existing Beats Battery script (as below), I would need to only change the MAC_ADDR? Thanks.

use framework "Foundation"

use framework "IOBluetooth"

use scripting additions

set pairedNames to (( current application's IOBluetoothDevice's pairedDevices())'s valueForKey:"nameOrAddress") as list

set connectedValue to (( current application's IOBluetoothDevice's pairedDevices())'s valueForKey:"connected") as list

set btInfo to {}

set i to 0

repeat with i from 1 to count pairedNames

set btInfo to btInfo & ( item i of pairedNames & ", " & item i of connectedValue) as list

end repeat

set i to 0

set deviceConnected to false

repeat with i from 1 to count btInfo

if item i of btInfo contains "Beats" and item i of btInfo contains ", 1" then

set deviceConnected to true

else if item i of btInfo contains "My Beats" and item i of btInfo contains ", 1" then

set deviceConnected to true

end if

end repeat

if deviceConnected is true then

set batteryLevel to do shell script "BLUETOOTH_DEFAULTS=$(defaults read /Library/Preferences/com.apple.Bluetooth); SYSTEM_PROFILER=$(system_profiler SPBluetoothDataType); MAC_ADDR=$(grep -b2 "Minor Type: Headphones"<<<"${SYSTEM_PROFILER}"|awk '/Address/{print $3}'); CONNECTED=$(grep -ia6 "${MAC_ADDR}"<<<"${SYSTEM_PROFILER}"|awk '/Connected: Yes/{print 1}'); BLUETOOTH_DATA=$(grep -ia6 '"'"${MAC_ADDR}"'"'<<<"${BLUETOOTH_DEFAULTS}"); BATTERY_LEVELS=("BatteryPercentSingle"); if [[ "${CONNECTED}" ]]; then for I in "${BATTERY_LEVELS[@]}"; do declare -x "${I}"="$(awk -v pat="${I}" '$0~pat{gsub (";",""); print $3 }'<<<"${BLUETOOTH_DATA}")"; [[ ! -z "${!I}" ]] && OUTPUT="${OUTPUT}$(awk <<<"${I}")${!I}%"; done; printf "%s" "${OUTPUT}"; else printf "%s Not Connected" "${OUTPUT}"; fi"

return "Battery: " & batteryLevel

else

return ""

end if