View Single Post
Posts: 90 | Thanked: 35 times | Joined on Jan 2012
#70
Originally Posted by thp View Post
That should help:

Code:
import dbus

bus = dbus.SystemBus()

bluez = bus.get_object('org.bluez', '/')
adapter_path = bluez.ListAdapters(
    dbus_interface='org.bluez.Manager')[0]
adapter = bus.get_object('org.bluez', adapter_path)
powered = adapter.GetProperties(
    dbus_interface='org.bluez.Adapter')['Powered']

if powered:
    print 'Bluetooth on'
else:
    print 'Bluetooth off'
That works great - thanks!
Obviously it only updates when something else has changed but it will do the intended job. I have my Meecast update every 30mins so it'll do.
There's a strange line feed in there from the script but that might be due to me being lazy and creating the script file on my windows laptop.