aboutsummaryrefslogtreecommitdiff
path: root/ParrotZikTrayMac
diff options
context:
space:
mode:
authorDmitry Moiseev <m0sia@m0sia.ru>2014-01-11 09:01:21 -0800
committerDmitry Moiseev <m0sia@m0sia.ru>2014-01-11 09:01:21 -0800
commit240d800485b583a9d45e1c4a80e2ca766cbf8431 (patch)
treeee7c8768227b3d9f704721fb7f12e7613e2a4472 /ParrotZikTrayMac
parentb34909762b01d174d3140e000537d84ed0f1042a (diff)
downloadpyParrotZikTCP-240d800485b583a9d45e1c4a80e2ca766cbf8431.tar.xz
pyParrotZikTCP-240d800485b583a9d45e1c4a80e2ca766cbf8431.zip
Removed obsolete mac os x tray script
Diffstat (limited to 'ParrotZikTrayMac')
-rw-r--r--ParrotZikTrayMac214
1 files changed, 0 insertions, 214 deletions
diff --git a/ParrotZikTrayMac b/ParrotZikTrayMac
deleted file mode 100644
index 7179386..0000000
--- a/ParrotZikTrayMac
+++ /dev/null
@@ -1,214 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import re
-import os
-import ParrotZikMac
-import rumps
-from binplist import binplist
-import BluetoothPairedDevices
-
-
-UPDATE_FREQUENCY = 30 # seconds
-
-class ParrotZikIndicator:
- def __init__(self):
-
- self.menu_setup()
-
- self.connected=False
-
- self.p = re.compile('00\-88\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}')
-
- if sys.platform=="darwin":
- self.icon_directory = os.path.dirname(os.path.realpath(sys.argv[0])) + os.path.sep+ 'share' + os.path.sep+'icons' + os.path.sep+'zik'+ os.path.sep
- self.app = rumps.App("Parrot Zik Tray", icon= self.icon_directory+ os.path.sep + "zik-audio-headset.png")
- self.app.menu = self.menu
-
- return
-
- def pos(menu, ignore, icon):
- return (Gtk.StatusIcon.position_menu(menu, icon))
-
- def setIcon(self, name):
- if sys.platform=="linux2":
- self.statusicon.set_icon(name)
- else:
- self.statusicon.set_from_file(self.icon_directory+name+'.png')
-
- def gtk_right_click_event(self, icon, button, time):
- if not self.menu_shown:
- self.menu_shown=True
- self.menu.popup(None, None, gtk.status_icon_position_menu, button, time, self.statusicon)
- else:
- self.menu_shown=False
- self.menu.popdown()
-
-
- def menu_setup(self):
- self.menu = []
-
- self.info_item = rumps.MenuItem("Parrot Zik Not connected..")
- self.menu.append(self.info_item)
-
- self.check = rumps.MenuItem("Noise Cancellation")
- self.menu.append(self.check)
-
- self.check2 = rumps.MenuItem("Auto Connection")
- self.menu.append(self.check2)
-
- self.check3 = rumps.MenuItem("Lou Reed Mode")
- self.menu.append(self.check3)
-
- self.check4 = rumps.MenuItem("Concert Hall Mode")
- self.menu.append(self.check4)
-
-
- def EstablishConnection(self):
- if self.connected:
- if not self.parrot.sock:
- print "Lost connection"
- self.connected = False
- else:
- print "Connection already established"
- else:
- mac=BluetoothPairedDevices.ParrotZikMac()
- if mac:
- self.parrot = ParrotZik.ParrotZik(mac)
- if not self.parrot.sock:
- print "Failed to connect to Parrot Zik %s" % mac
- return False
-
- self.connected = True
- self.name = self.parrot.getFriendlyName()
- self.version = self.parrot.getVersion()
-
- self.check.set_sensitive(True)
- self.check2.set_sensitive(True)
- self.check3.set_sensitive(True)
- self.check4.set_sensitive(True)
-
- if self.parrot.getNoiseCancel() == "true":
- self.check.set_active(True)
- else:
- self.check.set_active(False)
-
- if self.parrot.getAutoConnection() == "true":
- self.check2.set_active(True)
- else:
- self.check2.set_active(False)
-
- if self.parrot.getLouReedMode() == "true":
- self.check3.set_active(True)
- else:
- self.check3.set_active(False)
-
- if self.parrot.getParrotConcertHall() == "true":
- self.check4.set_active(True)
- else:
- self.check4.set_active(False)
-
- self.CheckBattery()
- return True
-
- def toggleANC(self,widget):
- if self.connected:
- if self.check.get_active():
- self.parrot.setNoiseCancel("true")
- else:
- self.parrot.setNoiseCancel("false")
-
- def toggleAuto(self,widget):
- if self.connected:
- if self.check2.get_active():
- self.parrot.setAutoConnection("true")
- else:
- self.parrot.setAutoConnection("false")
-
- def toggleLouReedMode(self,widget):
- if self.connected:
- if self.check3.get_active():
- self.parrot.setLouReedMode("true")
- else:
- self.parrot.setLouReedMode("false")
- if self.parrot.getLouReedMode() == "true":
- self.check3.set_active(True)
- else:
- self.check3.set_active(False)
-
- if self.parrot.getParrotConcertHall() == "true":
- self.check4.set_active(True)
- else:
- self.check4.set_active(False)
-
- def toggleParrotConcertHall(self,widget):
- if self.connected:
- if self.check4.get_active():
- self.parrot.setParrotConcertHall("true")
- else:
- self.parrot.setParrotConcertHall("false")
-
- if self.parrot.getLouReedMode() == "true":
- self.check3.set_active(True)
- else:
- self.check3.set_active(False)
-
- if self.parrot.getParrotConcertHall() == "true":
- self.check4.set_active(True)
- else:
- self.check4.set_active(False)
-
- def CheckBattery(self):
- if self.connected:
- print "Updating battery"
- self.batteryLevel = int(self.parrot.getBatteryLevel())
-
- if self.parrot.BatteryCharging:
- self.batteryLevel = "Charging"
- self.setIcon("zik-battery-charging")
- self.batteryLevel="Unknown"
- self.batteryState="Charging"
- elif self.batteryLevel>80:
- self.setIcon("zik-battery-100")
- self.batteryState="In Use"
- elif self.batteryLevel>60:
- self.setIcon("zik-battery-080")
- self.batteryState="In Use"
- elif self.batteryLevel>40:
- self.setIcon("zik-battery-060")
- self.batteryState="In Use"
- elif self.batteryLevel>20:
- self.setIcon("zik-battery-040")
- self.batteryState="In Use"
- else:
- self.setIcon("zik-battery-low")
- self.batteryState="In Use"
-
- self.info_item.set_label("Connected to: "+self.name+
- "\nFirmware version: "+self.version+
- "\nState: "+self.batteryState+
- "\nBattery Level: "+str(self.batteryLevel))
- else:
- self.setIcon("zik-audio-headset")
- self.info_item.set_label("Parrot Zik Not connected..")
- self.check.set_sensitive(False)
- self.check2.set_sensitive(False)
- self.check3.set_sensitive(False)
- self.check4.set_sensitive(False)
- return True
-
- # def show_about_dialog(self, widget):
- # about_dialog = gtk.AboutDialog()
-
- # about_dialog.set_destroy_with_parent(True)
- # about_dialog.set_name("Parrot Zik Tray")
- # about_dialog.set_version("0.1")
- # about_dialog.set_authors(["Dmitry Moiseev m0sia@m0sia.ru"])
- # about_dialog.run()
- # about_dialog.destroy()
-
-
-if __name__ == "__main__":
- indicator = ParrotZikIndicator()
- indicator.EstablishConnection()
- indicator.app.run() \ No newline at end of file