home · contact · privacy
Add caps lock indicator to i3status bar.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 17 Apr 2017 01:09:43 +0000 (03:09 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 17 Apr 2017 01:09:43 +0000 (03:09 +0200)
bin/i3status_wrapper.py [new file with mode: 0755]
dotfiles/user/thinkpad/W530/i3status.conf
dotfiles/user/thinkpad/minimal/i3

diff --git a/bin/i3status_wrapper.py b/bin/i3status_wrapper.py
new file mode 100755 (executable)
index 0000000..aa7b7c2
--- /dev/null
@@ -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))
index db87c5ad67c16d32fb720912466a63b0768e545c..f566ffe15ee3bd6da4ff94fd2f310f31b595a315 100644 (file)
@@ -2,8 +2,8 @@
 
 # Activate colors; set update interval of one second.
 general {
-        colors = true
-        interval = 1
+  colors = true
+  interval = 1
 }
 
 # Selection / order of status elements.
index b7177b2b3390e075aabb35c063e6c2f52705d3f1..a0e6c43a58a7612d7f760109b669faf6bef33c60 100644 (file)
@@ -79,5 +79,5 @@ bindsym $mod+Shift+P          exit
 
 # Select "i3status" as i3 status bar.
 bar {
-        status_command            i3status
+  status_command i3status | ~/config/bin/i3status_wrapper.py
 }