aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/i3blocks/.local/bin/i3blocks-notmuch
blob: a81fae6f929ef85b85211412475a64058124ee4c (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
#!/usr/bin/env python3

import notmuch
import os

ICON = "\U000f01ee"  # 󰇮


def main():
    # Workaround for bug in the notmuch module's default config resolution
    if os.environ.get("NOTMUCH_CONFIG") is None:
        os.environ["NOTMUCH_CONFIG"] = os.path.join(
            os.environ.get(
                "XDG_CONFIG_HOME", os.path.join(os.path.expanduser("~"), ".config")
            ),
            "notmuch",
            os.environ.get("NOTMUCH_PROFILE", "default"),
            "config",
        )

    count = notmuch.Database().create_query("tag:unread").count_messages()

    print(f" {ICON} {count} \n")
    if count > 10:
        print(f"#{os.environ.get("BASE16_COLOR_00_HEX")}")
        print(f"#{os.environ.get("BASE16_COLOR_08_HEX")}")
    elif count > 0:
        print(f"#{os.environ.get("BASE16_COLOR_00_HEX")}")
        print(f"#{os.environ.get("BASE16_COLOR_0A_HEX")}")


if __name__ == "__main__":
    main()