def update(): pct = float(psutil.cpu_percent()) ic = tools.icon(fa.icons['tachometer']) g = tools.bar(pct / 100.0) print("%s %s %0.f%%" % (ic, g, pct)) sys.stdout.flush()
def update(): now = datetime.datetime.now() txt = now.strftime('%a %m/%d %H:%M') ic = tools.icon('') print("%s %s" % (ic, txt)) sys.stdout.flush()
def update(): ic = tools.icon(fa.icons['tachometer']) pcts = [core / 100.0 for core in psutil.cpu_percent(percpu=True)] g = tools.pango(graph(pcts), foreground=tools.GRAPH_COLOR, background=tools.GRAPH_BACKGROUND_COLOR, font_size='small') print("%s %s" % (ic, g)) sys.stdout.flush()
def update(): mixer = alsaaudio.Mixer('Master') volumes = mixer.getvolume() pct = sum(volumes) / len(volumes) mutes = mixer.getmute() muted = sum(mutes) != 0 # TODO: pull these from fontawesome if muted: ic = tools.icon(fa.icons['volume-off']) elif pct < 30: ic = tools.icon(fa.icons['volume-down']) else: ic = tools.icon(fa.icons['volume-up']) print("%s %d%%" % (ic, int(pct))) sys.stdout.flush()
def update(): logging.info('update') pkgs = proc.check_output(['checkupdates']).decode('utf-8') count = len(pkgs.split('\n')) - 1 if count > 0: icon = tools.icon(fa.icons['gift']) print("%s %d" % (icon, count)) else: print() sys.stdout.flush()
def update(): vmem = psutil.virtual_memory() ic = tools.icon(fa.icons['microchip']) g = tools.bar(vmem.percent / 100.0) used = vmem.used / 10**9 total = vmem.total / 10**9 print("%s %s %.1f/%.1fGB" % (ic, g, used, total)) sys.stdout.flush()
def print_status(): global artist, title, prev_status if artist and title: status = tools.icon(fa.icons['music']) + cgi.escape(' ' + artist + ' - ' + title) else: status = '' if status != prev_status: print(status) sys.stdout.flush() prev_status = status
def update(): try: connections = list(wifi.Cell.all(interface)) except wifi.exceptions.InterfaceError as e: connections = [] if len(connections) == 0: icon = tools.icon(fa.icons['wifi']) # TODO: get a wifi off icon text = "No WiFi" elif len(connections) == 1: icon = tools.icon(fa.icons['wifi']) qual_str = connections[0].quality vals = re.match(r"^(\d+)/(\d+)", qual_str).groups() percent = int(float(vals[0]) / float(vals[1]) * 100) text = "%s %d%%" % (connections[0].ssid, percent) else: icon = tools.icon(fa.icons['wifi']) # TODO: scanning icon? text = "Scanning..." print("%s %s" % (icon, text)) sys.stdout.flush()
output = proc.check_output(['acpi', 'battery']).decode('utf-8') # Acpi prints a message to stderr and nothing to stdout if the sytstem doesn't # have a battery. This happens when this script is run on a desktop system if len(output) == 0: sys.exit(1) pct = int(re.search('(\d+)%', output).group(1)) icons = [ fa.icons['battery-empty'], # 0%-12.5% fa.icons['battery-quarter'], # 12.5%-37.5% fa.icons['battery-half'], fa.icons['battery-three-quarters'], fa.icons['battery-full'], ] i = round(pct / 25) # urgent color if battery is very low foreground = tools.URGENT_COLOR if i == 0 else tools.ICON_COLOR ic = tools.icon(icons[i], foreground=foreground) if is_charging(): ic = tools.icon(fa.icons['bolt'], foreground=foreground) + ' ' + ic print("%s %d%%" % (ic, pct))
output = proc.check_output(["acpi", "battery"]).decode("utf-8") # Acpi prints a message to stderr and nothing to stdout if the sytstem doesn't # have a battery. This happens when this script is run on a desktop system if len(output) == 0: sys.exit(1) pct = int(re.search("(\d+)%", output).group(1)) icons = [ fa.icons["battery-empty"], # 0%-12.5% fa.icons["battery-quarter"], # 12.5%-37.5% fa.icons["battery-half"], fa.icons["battery-three-quarters"], fa.icons["battery-full"], ] i = round(pct / 25) # urgent color if battery is very low foreground = tools.URGENT_COLOR if i == 0 else tools.ICON_COLOR ic = tools.icon(icons[i], foreground=foreground) if is_charging(): ic = tools.icon(fa.icons["bolt"], foreground=foreground) + " " + ic print("%s %d%%" % (ic, pct))