From 676a76ea164689e1342effbfe248fdd7487e000c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Thu, 24 Sep 2020 19:16:51 +0200 Subject: [PATCH] feat(i3status-rust): move mail setup to notmuch --- dot/i3status-rust.nix | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/dot/i3status-rust.nix b/dot/i3status-rust.nix index dca438a..31b2b8e 100644 --- a/dot/i3status-rust.nix +++ b/dot/i3status-rust.nix @@ -1,5 +1,7 @@ { pkgs, wifi-interface, colours, batteryBlock }: let + inherit (pkgs) lib; + setsid = script: pkgs.writers.writeDash "setsid-command" '' ${pkgs.utillinux}/bin/setsid ${script} @@ -102,19 +104,13 @@ in { { block = "custom"; interval = 30; - command = pkgs.writers.writeDash "mail-new" '' - for dir in /home/kfm/mail/*/Inbox/new - do - new_mail="$(find "$dir" -type f | wc --lines)" - [ "$new_mail" = 0 ] && printf "📭" || printf "📬" - echo "$new_mail" - done | paste --serial --delimiters=" " - - ''; - on_click = pkgs.writers.writeDash "mail-update" '' - ${pkgs.libnotify}/bin/notify-send --app-name="📧 MBSync" "Updating email." \ - && ${pkgs.isync}/bin/mbsync --all \ - && ${pkgs.libnotify}/bin/notify-send --app-name="📧 MBSync" "Email updated." - ''; + command = + let query = "tag:unread"; + in pkgs.writers.writeDash "count-new-mail" '' + mail_count="$(${pkgs.notmuch}/bin/notmuch search ${lib.escapeShellArg query} | wc -l)" + [ "$mail_count" = 0 ] && printf "📭" || printf "📬" + echo "$mail_count" + ''; } { block = "net";