X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=bin%2Fi3status_wrapper.py;fp=bin%2Fi3status_wrapper.py;h=aa7b7c2b85cd67077000351173ba2090915085d2;hb=22c6e31ac61327b879659da4b36e180861e1e947;hp=0000000000000000000000000000000000000000;hpb=77e7c55b878b35a41aace3d688ac9082f1795266;p=config diff --git a/bin/i3status_wrapper.py b/bin/i3status_wrapper.py new file mode 100755 index 0000000..aa7b7c2 --- /dev/null +++ b/bin/i3status_wrapper.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Inspired by http://code.stapelberg.de/git/i3status/tree/contrib/wrapper.py + +import sys +import json +import subprocess + +def print_nonbuffered(message): + sys.stdout.write(message) + sys.stdout.flush() + +if __name__ == '__main__': + print_nonbuffered(sys.stdin.readline()) + print_nonbuffered(sys.stdin.readline()) + while True: + line, prefix = sys.stdin.readline(), '' + if line.startswith(','): + line, prefix = line[1:], ',' + j = json.loads(line) + if '1' == subprocess.getoutput('xset q | grep LED')[65]: + j.insert(len(j), {'full_text' : 'CAPS', + 'separator_block_width': 40, + 'color': '#FF0000'}) + print_nonbuffered(prefix+json.dumps(j))