Ejemplo n.º 1
0
#!/usr/bin/env python3

import tools
import psutil
import time
import sys
import fontawesome as fa

INTERVAL = 0.5

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()

tools.autoreload_xresources_with_callback(update)

while True:
    update()
    time.sleep(INTERVAL)

Ejemplo n.º 2
0
    return re.search('([^\(]+)', title).group(0)

def on_play(player):
    print_status()

def on_pause(player):
    print_status()

def on_quit(player):
    global artist, title
    artist, title = None, None
    print_status()

main = GLib.MainLoop()

tools.autoreload_xresources_with_callback(print_status)

while True:
    try:
        # note: this will fail if no player is currently running. This is fine -
        # we catch the exception, then try to connect again later.
        player = Playerctl.Player()
        if player.get_property('player-name') == None:
            raise RuntimeError('No player available')
        player.on('metadata', on_metadata)  
        player.on('exit', on_quit)

        artist = player.get_artist()
        title = filter_title(player.get_title())
        print_status()