diff options
author | Francois Andriot <francois.andriot@free.fr> | 2012-10-21 19:23:00 +0200 |
---|---|---|
committer | Francois Andriot <francois.andriot@free.fr> | 2012-10-21 19:23:00 +0200 |
commit | 59daf455b483742c6c47099652117074df37889a (patch) | |
tree | 5271c465e9468df4e8fe1814bdb413164b40823e /redhat/extras/kdebluetooth/kblueplugd.bluez3 | |
parent | 7834467b40a454432c3f8d84b6b43e299afe4933 (diff) | |
download | tde-packaging-59daf455b483742c6c47099652117074df37889a.tar.gz tde-packaging-59daf455b483742c6c47099652117074df37889a.zip |
RHEL/Fedora/MGA/MDV/Suse: update extras for TDE 3.5.13.1
Diffstat (limited to 'redhat/extras/kdebluetooth/kblueplugd.bluez3')
-rw-r--r-- | redhat/extras/kdebluetooth/kblueplugd.bluez3 | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/redhat/extras/kdebluetooth/kblueplugd.bluez3 b/redhat/extras/kdebluetooth/kblueplugd.bluez3 new file mode 100644 index 000000000..e954b9e42 --- /dev/null +++ b/redhat/extras/kdebluetooth/kblueplugd.bluez3 @@ -0,0 +1,59 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- +""" +Copyright (C) 2007 Achim Bohnet <allee@kubuntu.org> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +""" + +import sys +from PyQt4 import QtCore, Qt +import dbus +import dbus.mainloop.qt +import distutils.spawn + +kbtcmd = [ 'kbluetooth' ] +quitprogs = [ 'kdebluetooth', 'kbluemon', 'kinputwizard' ] # FIXME: quit kbluelock too? + + +app = Qt.QCoreApplication(sys.argv) + +dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True) +bus = dbus.SystemBus() + +try: + manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), 'org.bluez.Manager') +except: + print "Unable to connect to bluez." + sys.exit(1) + +if len(manager.ListAdapters()): + print "# of devices at startup:", len(manager.ListAdapters()) + distutils.spawn.spawn(kbtcmd) +else: + print "No BT device found" + + +def slotAdapterAdded(device): + print "bt dev added:", device, "# of devices:", len(manager.ListAdapters()) + distutils.spawn.spawn(kbtcmd) + +def slotAdapterRemoved(device): + print "bt dev removed:", device, "# num of devices:", len(manager.ListAdapters()) + if len(manager.ListAdapters()) == 0: + for p in quitprogs: + print "exiting:", p, " ..." + try: + distutils.spawn.spawn(['dcop', p, 'MainApplication-Interface', 'quit']) + except: + pass + +manager.connect_to_signal("AdapterAdded", slotAdapterAdded) +manager.connect_to_signal("AdapterRemoved", slotAdapterRemoved) + +print "waiting for bt device (un)plug events ..." + +app.exec_() |