Do you mean upload .bttpreset file?
As for automatically change airpods icon based on the model, it's possible!!
There is a key-value pair in com.apple.Bluetooth.plist called ProductID, which uniquely identifies the product. The screenshot below shows all the information you can get, VendorID and ProductID uniquely determines a product, in my case, 76 stands for Apple, and 8206 stands for AirPods Pro.
Below shows an example code, you can do all the artwork or optimizations.
use framework "IOBluetooth"
use scripting additions
set deviceList to current application's IOBluetoothDevice's pairedDevices()
set devNames to (deviceList's valueForKey:"name") as list
set devStatus to (deviceList's valueForKey:"connected") as list
set devAddress to (deviceList's valueForKey:"addressString") as list
--Add AirPods base64 iconData here, add new line if newer model is released.
set airpods_iconData to "emmm"
set airpods_pro_iconData to "emmm_pro"
--Set default icon and battery info to make the code more tidy
set batteryText to formatValue("0", "π
") & "
" & formatValue("0", "π
‘")
set currentModelIcon to airpods_iconData
tell application "BetterTouchTool" to set AirPodsName to get_string_variable "AirPodsWg_DevceName"
if devNames contains AirPodsName then
--Device is found
repeat with i from 1 to count devNames
if (item i of devNames) = AirPodsName then
--Get index of AirPods in the list and save connection status and MAC address value
set connectValue to item i of devStatus
set MAC_addr to item i of devAddress
if connectValue = 1 then
--Connected, update battery info using built-in tool "PlistBuddy"
set BatteryLeft to do shell script "/usr/libexec/PlistBuddy -c \"print :DeviceCache:" & MAC_addr & ":BatteryPercentLeft\" /Library/Preferences/com.apple.Bluetooth.plist"
set BatteryRight to do shell script "/usr/libexec/PlistBuddy -c \"print :DeviceCache:" & MAC_addr & ":BatteryPercentRight\" /Library/Preferences/com.apple.Bluetooth.plist"
set ProductID to do shell script "/usr/libexec/PlistBuddy -c \"print :DeviceCache:" & MAC_addr & ":ProductID\" /Library/Preferences/com.apple.Bluetooth.plist"
set batteryText to formatValue(BatteryLeft, "π
") & "
" & formatValue(BatteryRight, "π
‘")
--set corresponding icon based on product id, I ignored vendorID for simplicity
if ProductID = "8206" then
--AirPods Pro
set currentModelIcon to airpods_pro_iconData
--else if ProductID = "xxxx" then --Add product ID of new model here
--set currentModelIcon to newModel_iconData
else
--Default model: AirPods
set currentModelIcon to airpods_iconData
end if
end if
--return to break repeat loop
return jsonData(currentModelIcon, batteryText)
end if
end repeat
else
--Device not found, return default data
return jsonData(currentModelIcon, batteryText)
end if
--Adding utf icon and % character
on formatValue(BatteryLevel, prefix)
if BatteryLevel = "0" then
--If one of AirPods is in the case, battery would be 0
return prefix & "NC"
else
return prefix & BatteryLevel & "%"
end if
end formatValue
--Format into json data that BTT can recognize
on jsonData(icon, batteryInfo)
return "{\"text\":\"" & batteryInfo & "\", \"icon_data\": \"" & icon & "\", \"background_color\": \"47,55,65,255\"}"
end jsonData
For the battery of the case, you can actually get the data from that plist, but it is only available when you open the case and it became 0 if the case is closed. My thought is to create another button to display the case battery, and we must update the case battery manually by long-press or whatever.
@K2DesignLab Can you share your thoughts?