From 4bc5fd8ef2fc67b5352927b0a4ae0c8b9ebade93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Yule=20B=C3=A4dorf?= Date: Tue, 26 Mar 2024 22:20:39 +0100 Subject: [PATCH] email: enable imapnotify with automatic fetching --- pkgs/check-mail.nix | 14 -------------- pkgs/default.nix | 1 - users/b12f/email.nix | 5 +++-- 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 pkgs/check-mail.nix diff --git a/pkgs/check-mail.nix b/pkgs/check-mail.nix deleted file mode 100644 index 7a5390e..0000000 --- a/pkgs/check-mail.nix +++ /dev/null @@ -1,14 +0,0 @@ -self: -with self; '' - ${offlineimap}/bin/offlineimap - - for dir in ~/Mail/* - do - unread=$(find "''${dir}/INBOX/" -type f | grep -vE ',[^,]*S[^,]*$') - - if [ ! -z "''${unread}" ]; then - inbox=$(basename $dir) - ${libnotify}/bin/notify-send "''${inbox} has unread mail" - fi - done -'' diff --git a/pkgs/default.nix b/pkgs/default.nix index 6c5eef6..4ef1df7 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -13,7 +13,6 @@ with prev; { mu = writeShellScriptBin "mu" (import ./mu.nix final); p = writeShellScriptBin "p" (import ./p.nix final); present-md = writeShellScriptBin "present-md" (import ./present-md.nix final); - check-mail = writeShellScriptBin "check-mail" (import ./check-mail.nix final); s = writeShellScriptBin "s" (import ./s.nix final); sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final); sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final); diff --git a/users/b12f/email.nix b/users/b12f/email.nix index 2b96db4..ca3d00f 100644 --- a/users/b12f/email.nix +++ b/users/b12f/email.nix @@ -39,9 +39,11 @@ with lib; let tls.useStartTls = true; }; + offlineimap.enable = true; imapnotify = { enable = true; boxes = [ "INBOX" ]; + onNotify = "${pkgs.offlineimap}/bin/offlineimap -a ${address}"; onNotifyPost = "${pkgs.libnotify}/bin/notify-send '${address} has new mail'"; }; msmtp.enable = true; @@ -58,13 +60,11 @@ with lib; let +Trash ''; }; - offlineimap.enable = true; } // (if args ? "config" then args.config else {}); in { users.users."${psCfg.user.name}".packages = with pkgs; [ w3m mailto-mutt - check-mail ]; home-manager.users."${psCfg.user.name}" = rec { @@ -119,6 +119,7 @@ in { ]; }; + services.imapnotify.enable = true; programs.offlineimap.enable = true; programs.msmtp.enable = true; programs.neomutt = {