This can by done by involving some command-line foo:
set btStatus to do shell script "/usr/local/bin/blueutil power"
set enStatus to do shell script "ifconfig en0 | grep 'status' | cut -d ':' -f 2 | tr -d ' '"
if btStatus = "1" then
set bluetoothEnabled to true
log "Bluetooth is enabled"
else if btStatus = "0" then
set bluetoothEnabled to false
log "Bluetooth is disabled"
else
log "Could not determine Bluetooth status"
end if
if enStatus = "active" then
set ethernetEnabled to true
log "Ethernet is enabled"
else if enStatus = "inactive" then
set ethernetEnabled to false
log "Ethernet is disabled"
else
log "Could not determine Ethernet status"
end if
The interesting parts are the first two lines.
Please note:
- This requires blueutil to be installed (you can install it easily using Homebrew)
- You might need to change
en0
to the interface you want to check (you can get a list of all interfaces by entering ifconfig
into a terminal)
- You might need to change the path to
blueutil
(depending how you installed it)