configfiles/scripts/bspwmbar.py

33 lines
828 B
Python

#!/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)