aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-04 15:04:28 +0200
committerneodarz <neodarz@neodarz.net>2019-09-04 15:04:28 +0200
commitd0e8cf0db6f86406d2c528b35343bb3d08c9e9b8 (patch)
tree9ac1574044fbbbcf46a025b5e34ec5be45ef2664
parentc14e7e61344d67d4233beb9f1e7a9f314d2b22f5 (diff)
downloaddotfiles_ascii-d0e8cf0db6f86406d2c528b35343bb3d08c9e9b8.tar.xz
dotfiles_ascii-d0e8cf0db6f86406d2c528b35343bb3d08c9e9b8.zip
Add headset battery info
-rw-r--r--i3pystatus/.config/i3pystatus/conf.py11
-rw-r--r--i3pystatus/.config/i3pystatus/headset.py21
2 files changed, 32 insertions, 0 deletions
diff --git a/i3pystatus/.config/i3pystatus/conf.py b/i3pystatus/.config/i3pystatus/conf.py
index 1d7f4c5..1a09983 100644
--- a/i3pystatus/.config/i3pystatus/conf.py
+++ b/i3pystatus/.config/i3pystatus/conf.py
@@ -226,6 +226,17 @@ status.register("text",
# text="|",
# hints = {"separator": False, "separator_block_width": 0},)
+status.register("shell",
+ command="python ~/.config/i3pystatus/headset.py",
+ interval=1,
+ hints = {"separator": False, "separator_block_width": 0},)
+
+status.register("text",
+ text="|",
+ hints = {"separator": False, "separator_block_width": 0},)
+
+
+
status.register("redshift",
hints = {"separator": False, "separator_block_width": 0},)
diff --git a/i3pystatus/.config/i3pystatus/headset.py b/i3pystatus/.config/i3pystatus/headset.py
new file mode 100644
index 0000000..8668300
--- /dev/null
+++ b/i3pystatus/.config/i3pystatus/headset.py
@@ -0,0 +1,21 @@
+import json
+
+try:
+ with open('/tmp/parrotZikBattery') as json_data:
+ data = json.load(json_data)
+
+ try:
+ if "data" in data:
+ out = str(data["data"]["level"])+"% ("+data["data"]["state"]+")"
+ print(out)
+ elif "error" in data:
+ print(data["error"])
+ except TypeError:
+ print("X")
+except OSError as e:
+ if e.errno == 2:
+ print("X")
+ else:
+ print(e)
+
+