def update(self): capacity = self.battery.Percentage online = self.ac.Online if (online or capacity > _WARNING_LEVEL) and self.warned: self.button.colors = self.colors check_dialog(_WARNING_NAME) self.warned = False elif not online and capacity <= _WARNING_LEVEL and not self.warned: self.button.colors = self.warn_colors dialog('WARNING! Battery level is low!', _WARNING_NAME, colors=self.warn_colors) self.warned = True self.button.label = 'B: %2d%%%s' % (capacity, _CHARGE_STATE[online])
def _toggle_dialog(self, name): if check_dialog(name): return info = call('sensors') if self.gpu: info += '\n\n' + call(*self.gpu[1:]) dialog(info, name)
def toggle_dialog(self): name = self.button.name if check_dialog(name): return if self.conn and self.iface[0] == 'wireless': dialog( ' IP: %s\n' ' Name: %s\n' 'Signal: %s%%\n' ' Speed: %s' % (self.conn[0], self.conn[1], self.conn[2], self.conn[4]), name) elif self.conn: dialog('IP: %s' % self.conn[0], name) elif self.iface: if self.iface[0] == 'wireless': target = 'wireless network "%s" ...' % self.iface[1] else: target = '%s interface ...' % self.iface[0] dialog('Connecting to %s' % target, name) else: dialog('Not connected', name)
def toggle_tz_time_dialog(self, name): if check_dialog(name): return sweden = call('date', env={'TZ': 'Europe/Stockholm'}) montreal = call('date', env={'TZ': 'America/Montreal'}) shanghai = call('date', env={'TZ': 'Asia/Shanghai'}) dialog(" Sweden: %s\n\nMontreal: %s\n\nShanghai: %s" % (sweden, montreal, shanghai), name)
def _toggle_dialog(self, name): if check_dialog(name): return dialog( 'Worked time:\n %s (%.2f)\n\nLunch:\n %s (%.2f)' % (self.work_time.get_time_worked(), self.work_time.get_time_worked_decimal(), self.work_time.get_time_lunched(), self.work_time.get_time_lunched_decimal()), name)
def toggle_meta_info(): if check_dialog(__name__): return info = spotify_property().Metadata artist = ', '.join((s for s in info['xesam:artist'])) album = info['xesam:album'] title = info['xesam:title'] length = long(info['mpris:length']) / 1000000L max_width = max(16, len(title), len(album) + 7, len(artist)) dialog(u'Spotify%0*s\n%s\n%s\n%s\n\n%s' % (max_width - 7, '[%02d:%02d]' % (length / 60, length % 60), '-' * max_width, artist, album, title) , __name__)
def _monitor_action(self, monitor): try: self.current_avg.append(int(_read(self.bat_current_now_path))) except: pass try: capacity = int(_read(self.bat_capacity_path)) if capacity > 100: capacity = 100 online = int(_read(self.ac_online_path)) if (online or capacity > _WARNING_LEVEL) and self.warned: self.colors = self.normcolors monitor.button.colors = self.colors check_dialog(_WARNING_NAME) self.warned = False elif not online and capacity <= _WARNING_LEVEL and not self.warned: self.colors = wmii.cache['urgentcolors'] monitor.button.colors = self.colors dialog('WARNING! Battery level is low!', _WARNING_NAME, colors=self.colors) self.warned = True except Exception, e: traceback.print_exc(sys.stdout) capacity = -1 online = 0 monitor.active = False
def toggle_dialog(self): name = self.button.name if check_dialog(name): return self.refresh() online = self.ac.Online time_to_full = self.battery.TimeToFull time_to_empty = self.battery.TimeToEmpty if online and time_to_full == 0: info = 'Fully charged' elif online: info = 'Charging - %s until charged' % _format_time(time_to_full) else: info = 'Discharging - %s remaining' % _format_time(time_to_empty) dialog(info, name, colors=self.colors)
def _toggle_dialog(self, name): if check_dialog(name): return try: current_now = sum(self.current_avg) / len(self.current_avg) charge_now = int(_read(self.bat_charge_now_path)) status = _read(self.bat_status_path) if status == 'Discharging': info = '%s - %s remaining' % ( status, _format_time(charge_now, current_now)) elif status == 'Charging': charge_full = int(_read(self.bat_charge_full_path)) info = '%s - %s until charged' % ( status, _format_time(charge_full - charge_now, current_now)) else: info = 'Status: %s' % status dialog(info, name, colors=self.colors) except Exception, e: traceback.print_exc(sys.stdout) dialog('Error', name)
def _toggle_dialog(self, name): if check_dialog(name): return free = call('free', '-h') df = call('df', '-h', '--type=tmpfs') dialog('%s\n\n%s' % (free, df), name)
def _toggle_dialog(self, name): if check_dialog(name): return dialog(call('top', '-b', '-i', '-n', '1'), name)
def toggle_dialog(self): name = self.button.name if check_dialog(name): return dialog(call('nm-tool'), name)