blob: f87f1d327e3a71a7da75ae6c1b8f328a341b27ca (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/env python3
import os
import subprocess
import requests
ICON = "\U000f046b" #
def get_count():
url = "https://miniflux.tobyvin.dev/v1/feeds/counters"
headers = {"X-Auth-Token": os.environ.get("MINIFLUX_TOKEN")}
resp = requests.get(url, headers=headers)
return sum(resp.json().get("unreads").values())
def main():
match int(os.environ.get("BLOCK_BUTTON", "0")):
case 1:
subprocess.run(["xdg-open", "https://miniflux.tobyvin.dev"])
try:
count = get_count()
except requests.exceptions.ConnectionError:
count = "x"
print(f" {ICON} {count} \n")
match count:
case str(c) | int(c) if c > 10:
print(f"#{os.environ.get("BASE16_COLOR_00_HEX")}")
print(f"#{os.environ.get("BASE16_COLOR_08_HEX")}")
case int(c) if c > 0:
print(f"#{os.environ.get("BASE16_COLOR_00_HEX")}")
print(f"#{os.environ.get("BASE16_COLOR_0A_HEX")}")
if __name__ == "__main__":
main()
|