summaryrefslogtreecommitdiffstats
path: root/debian/tdeblueplugd
diff options
context:
space:
mode:
Diffstat (limited to 'debian/tdeblueplugd')
-rw-r--r--debian/tdeblueplugd62
1 files changed, 62 insertions, 0 deletions
diff --git a/debian/tdeblueplugd b/debian/tdeblueplugd
new file mode 100644
index 0000000..7d3db40
--- /dev/null
+++ b/debian/tdeblueplugd
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# -*- coding: UTF-8 -*-
+"""
+Copyright (C) 2007 Achim Bohnet <[email protected]>
+
+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, QtGui
+import dbus
+#import dbus.mainloop.tqt3
+import dbus.mainloop.qt
+import distutils.spawn
+
+tdebtcmd = [ 'tdebluetooth' ]
+quitprogs = [ 'tdebluetooth', 'tdebluemon', 'tdeinputwizard' ] # FIXME: quit tdebluelock too?
+
+
+app = TQtGui.TQApplication(sys.argv)
+if app.isSessionRestored():
+ sys.exit(1)
+
+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_()
+#sys.exit(app.exec_())