1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/python
import urllib, os, time, datetime
from gi.repository import Gtk, GObject
from gi.repository import AppIndicator3 as appindicator
from helpers import FitBit
def openit(*args):
os.system("xdg-open http://www.fitbit.com")
def update(*args):
steps = FitBit.fetch(None)
print steps.steps
ind.set_label("%i steps" % steps.steps, "100 steps")
lst.get_child().set_text("Last updated: %s" % time.strftime("%H:%M"))
return True
if __name__ == "__main__":
# icon is expected to be in the same directory as the script.
iconPath = '/usr/share/icons/hicolor/32x32/apps/fitbit.png'
ind = appindicator.Indicator.new("fitbit-steps-indicator", iconPath,
appindicator.IndicatorCategory.APPLICATION_STATUS)
ind.set_status(appindicator.IndicatorStatus.ACTIVE)
ind.set_label("unknown steps", "100 steps")
menu = Gtk.Menu()
opn = Gtk.MenuItem("Open Fitbit")
menu.append(opn)
lst = Gtk.MenuItem("Last updated: ?????")
menu.append(lst)
menu.show_all()
opn.connect("activate", openit)
ind.set_menu(menu)
GObject.timeout_add_seconds(300, update)
update()
Gtk.main()
|