From 71f05bdaeeba143ab58d76ba2761248255d1670c Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Thu, 11 Jun 2015 11:53:12 +0200 Subject: [PATCH] Bspwmbar script parses subscribe output. unused --- scripts/bspwmbar.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/bspwmbar.py diff --git a/scripts/bspwmbar.py b/scripts/bspwmbar.py new file mode 100644 index 0000000..e83f2ff --- /dev/null +++ b/scripts/bspwmbar.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +OCCUPIED = 2 +ACTIVE = 1 +def parse(line): + line = line.lstrip("W") + info = {} + monitor = "" + for element in line.split(":"): + t,v = element[0],element[1:] + if t == "m" or t == "M": + monitor = v + info[v] = {} + elif t == "o" or t == "u": + info[monitor][v] = OCCUPIED + elif t == "O" or t == "U": + info[monitor][v] = OCCUPIED | ACTIVE + elif t == "f": + info[monitor][v] = 0 + elif t == "F": + info[monitor][v] = ACTIVE + + return info + +while True: + line = input().rstrip('\r\n') + info = parse(line) + c = "" + for desktop, flags in sorted(info["LVDS1"].items(), key=lambda e: e[0]): + t = { 0: "\ue001", ACTIVE: "\ue000"} + c += "%s " % t[flags & ACTIVE] + print(c) +