aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/i3blocks/.local/bin/i3blocks-miniflux
blob: 05224e2e44802c36b75283ee25d385b9df6a9fc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3

import os

import requests

ICON = "\U0000f09e"


def main():
    url = "https://miniflux.tobyvin.dev/v1/feeds/counters"
    headers = {"X-Auth-Token": os.environ.get("MINIFLUX_TOKEN")}
    resp = requests.get(url, headers=headers)
    count = sum(resp.json().get("unreads").values())

    print(f" {ICON} {count} \n")
    if count > 50:
        print(os.environ.get("black"))
        print(os.environ.get("red"))
    elif count > 0:
        print(os.environ.get("black"))
        print(os.environ.get("yellow"))


if __name__ == "__main__":
    main()