def create_menu(self): self.icon = DARK_ICONS[0] if utils.dark_mode() else ICONS[0] foreground_tasks, background_tasks = process.get_processes() suspender.manage(foreground_tasks, background_tasks) suspended_tasks = suspender.get_suspended_tasks() foreground_menu_items = filter( None, map(self.menu_item_for_process, foreground_tasks)) background_menu_items = filter( None, map( functools.partial(self.menu_item_for_process, suspendable=True), background_tasks)) suspended_menu_items = filter( None, map(functools.partial(self.menu_item_for_process, resumable=True), suspended_tasks)) self.clean_menu() self.menu = ([ rumps.MenuItem(TITLE_ABOUT % self.version(), callback=self.about), None, rumps.MenuItem(TITLE_CURRENT_PROCESSES), ] + foreground_menu_items + [ None, rumps.MenuItem(TITLE_OTHER_PROCESSES), ] + background_menu_items + [ None, rumps.MenuItem(TITLE_SUSPENDED_PROCESSES), ] + suspended_menu_items + [ None, rumps.MenuItem(TITLE_ON_ETHERNET if utils.on_ethernet( ) else TITLE_NOT_ON_ETHERNET), rumps.MenuItem(TITLE_QUIT, callback=self.quit), ])
def create_menu(self): self.icon = DARK_ICONS[0] if utils.dark_mode() else ICONS[0] self.menu = [ rumps.MenuItem(TITLE_ABOUT % self.version(), callback=self.about), None, rumps.MenuItem(TITLE_CURRENT_PROCESSES), None, rumps.MenuItem(TITLE_OTHER_PROCESSES), None, rumps.MenuItem(TITLE_SUSPENDED_PROCESSES), None, rumps.MenuItem(TITLE_QUIT, callback=self.quit), ] self.menu._menu.setDelegate_(self)
def get_icon(self, percent): icons = DARK_ICONS if utils.dark_mode() else ICONS iconIndex = 0 if not percent else max( 0, min(len(icons) - 1, int(percent * len(icons) / 70.0))) return icons[iconIndex]