From 813480d439488de2e1d5abe12a076c2b0140fd8f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 20 Jun 2014 16:03:31 +0200 Subject: add alsa plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugins/alsa | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/plugins/alsa (limited to 'examples/plugins/alsa') diff --git a/examples/plugins/alsa b/examples/plugins/alsa new file mode 100644 index 0000000..f11183b --- /dev/null +++ b/examples/plugins/alsa @@ -0,0 +1,32 @@ +# -*- python -*- + +# A xpybar configuration example testing the features of plugins.alsa + +import time +import threading + +from plugins.alsa import ALSA +from plugins.clock import Clock + + +OUTPUT, HEIGHT, YPOS, TOP = 0, 12 * len(ALSA.get_cards()), 24, True + + +clock = Clock(sync_to = 0.25 * Clock.SECONDS) +alsa_ = [[ALSA(ci, m) for m in ALSA.get_mixers(ci)] for ci in range(len(ALSA.get_cards()))] +cardnames = ALSA.get_cards() + +start_ = start +def start(): + start_() + async(lambda : clock.continuous_sync(lambda : bar.invalidate())) + +text_v = lambda v : '---' if v is None else ('%2i%%' % v)[:3] +read_m = lambda m : '%s: %s' % (m.mixername, ' '.join(text_v(v) for v in m.get_volume())) +read_c = lambda c : '%s │ %s' % (c[0].cardname, ' │ '.join(read_m(m) for m in c)) + +def redraw(): + text = '\n'.join(read_c(c) for c in alsa_) + bar.clear() + bar.draw_coloured_text(0, 10, 0, 2, text) + -- cgit v1.2.3-70-g09d2