From d0e8cf0db6f86406d2c528b35343bb3d08c9e9b8 Mon Sep 17 00:00:00 2001 From: neodarz Date: Wed, 4 Sep 2019 15:04:28 +0200 Subject: Add headset battery info --- i3pystatus/.config/i3pystatus/conf.py | 11 +++++++++++ i3pystatus/.config/i3pystatus/headset.py | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 i3pystatus/.config/i3pystatus/headset.py (limited to 'i3pystatus') 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) + + -- cgit v1.2.1