Bspwmbar script parses subscribe output. unused
This commit is contained in:
parent
604fe4aac5
commit
71f05bdaee
1 changed files with 33 additions and 0 deletions
33
scripts/bspwmbar.py
Normal file
33
scripts/bspwmbar.py
Normal file
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue