aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/config/i3pystatus/headset.py
blob: 8668300eb78ba3d3c615daf618029c041acb8764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)