check my automator apple script. The gole is to recive notifications on low batterie of…
- User
check my automator apple script. The gole is to recive notifications on low batterie of connected bluetooth devices like my mouse and keyboard
property warnThreshold : 60
on run try display notification "Bluetooth Batterie Check startet..." with title "Test"
set btData to do shell script "ioreg -r -c AppleDeviceManagementHIDEventService -a" set xml to do shell script "echo " & quoted form of btData & " | plutil -convert xml1 -o - -- - | xmllint --format -" set deviceList to paragraphs of (do shell script "echo " & quoted form of xml & " | xmllint --xpath '//dict[key=\"BatteryPercent\"]' - | grep -E '<string>|<integer>' | sed -E 's/<[^>]+>//g'") display notification "Gefundene Einträge: " & (count of deviceList) with title "Debug" set namesList to {} repeat with i from 1 to (count of deviceList) by 2 set end of namesList to item i of deviceList end repeat display notification "Geräte: " & (namesList as string) with title "Debug" set lowBatteryDevices to {} repeat with i from 1 to (count of deviceList) by 2 set devName to item i of deviceList set devLevelRaw to item (i + 1) of deviceList if containsOnlyDigits(devLevelRaw) then set devLevel to devLevelRaw as integer if devLevel < warnThreshold then set end of lowBatteryDevices to "„" & devName & "“: " & devLevel & "%" end if end if end repeat if (count of lowBatteryDevices) > 0 then set messageText to "Folgende Bluetooth-Geräte haben niedrigen Akku:" & return & (lowBatteryDevices as string) display dialog messageText buttons {"OK"} default button "OK" display notification messageText with title "🔋 Bluetooth Batterie Warnung" subtitle "Bitte Geräte aufladen" sound name "Funk" else display notification "Alle Bluetooth-Geräte haben genügend Akku." with title "Bluetooth Batterie Check" end if on error errMsg display dialog "Fehler beim Prüfen der Bluetooth-Batterien: " & errMsg buttons {"OK"} default button "OK" with icon caution end try
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.