aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/i3blocks/.local/bin/i3blocks-notmuch
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-05-20 21:31:21 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-05-20 21:31:21 -0500
commit4cfcc3e5863644aa7fed8e9347bb2bcbf47d7fb0 (patch)
treebde551f3544172d9cc4924e8d7da53dedca1c4e8 /i3blocks/.local/bin/i3blocks-notmuch
parent05904eb11ca70835e98f6f6240a6588855f8bfc5 (diff)
feat(i3blocks): add more scripts
Diffstat (limited to 'i3blocks/.local/bin/i3blocks-notmuch')
-rwxr-xr-xi3blocks/.local/bin/i3blocks-notmuch33
1 files changed, 33 insertions, 0 deletions
diff --git a/i3blocks/.local/bin/i3blocks-notmuch b/i3blocks/.local/bin/i3blocks-notmuch
new file mode 100755
index 0000000..b25c971
--- /dev/null
+++ b/i3blocks/.local/bin/i3blocks-notmuch
@@ -0,0 +1,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 > 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()