def set_auto(self, sender): sender.state = not sender.state if sender.state: # Turning auto mode ON self.set_presence_auto(sender) # Disable all callbacks (grays out menu items) self.meeting_menu.set_callback(None) self.commute_menu.set_callback(None) self.sick_menu.set_callback(None) self.vacation_menu.set_callback(None) self.remote_menu.set_callback(None) self.away_menu.set_callback(None) # Enable timer for timer in rumps.timers(): timer.start() elif not sender.state: # Turning auto mode OFF # Disable timer for timer in rumps.timers(): timer.stop() # Enable all callbacks self.meeting_menu.set_callback(self.set_meeting) self.commute_menu.set_callback(self.set_commute) self.sick_menu.set_callback(self.set_sick) self.vacation_menu.set_callback(self.set_vacation) self.remote_menu.set_callback(self.set_remote) self.away_menu.set_callback(self.set_presence_away)
def on_press(key): if key == keyboard.Key.esc: #print("stop") for t in rumps.timers(): # just in case things get out of sync t.stop() if key == keyboard.KeyCode(char='\\'): self.click_timer.start()
def start_work(self, sender): self.working = True self.resting = False self.intervals_done = 0 self.title = "{}m".format(self.worklength) ts = rumps.timers() for t in ts: """print t""" t.stop() t.start()
def check(_): print(rumps.timers())
def activetimers(_): print(rumps.timers())
def activetimers(_): print rumps.timers()
import urllib.request import rumps def ping(url): try: urllib.request.urlopen(url, timeout=1) return True except urllib.error.URLError as err: return False class InternetStatusApp(rumps.App): def __init__(self): super(InternetStatusApp, self).__init__(self.getAppTitle()) @rumps.timer(1) def updateTitle(self, sender): self.title = self.getStatus() def getStatus(self): return "🟢" if ping("http://www.google.com") else "🔴" app = InternetStatusApp() for timer in rumps.timers(): timer.start() app.run()