add email notifications

not required to run aerc, uses imapnotify and notmuch/polybar

closes #10
This commit is contained in:
Noah Masur 2023-04-02 23:16:44 -04:00
parent 0833a0009c
commit 4fefe54435
2 changed files with 25 additions and 10 deletions

View File

@ -27,10 +27,8 @@
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
programs.mbsync = { enable = true; }; programs.mbsync = { enable = true; };
services.mbsync = lib.mkIf pkgs.stdenv.isLinux { services.imapnotify.enable = pkgs.stdenv.isLinux && config.physical;
enable = true; programs.notmuch.enable = true;
frequency = "*:0/5";
};
accounts.email = { accounts.email = {
maildirBasePath = "${config.homePath}/mail"; maildirBasePath = "${config.homePath}/mail";
accounts = { accounts = {
@ -55,10 +53,11 @@
tls.enable = true; tls.enable = true;
}; };
imapnotify = { imapnotify = {
enable = false; enable = true;
boxes = [ ]; boxes = [ "Inbox" ];
onNotify = ""; onNotify = "${pkgs.isync}/bin/mbsync -a";
onNotifyPost = ""; onNotifyPost =
"${pkgs.libnotify}/bin/notify-send 'New mail arrived'";
}; };
maildir = { path = "main"; }; maildir = { path = "main"; };
mbsync = { mbsync = {
@ -72,7 +71,7 @@
}; };
}; };
mu.enable = false; mu.enable = false;
notmuch.enable = false; notmuch.enable = true;
passwordCommand = passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
builtins.toString ../../../private/mailpass.age builtins.toString ../../../private/mailpass.age

View File

@ -36,7 +36,7 @@
module-margin = 1; module-margin = 1;
modules-left = "i3"; modules-left = "i3";
modules-center = "xwindow"; modules-center = "xwindow";
modules-right = "pulseaudio date power"; modules-right = "mailcount pulseaudio date power";
cursor-click = "pointer"; cursor-click = "pointer";
cursor-scroll = "ns-resize"; cursor-scroll = "ns-resize";
enable-ipc = true; enable-ipc = true;
@ -101,6 +101,22 @@
# label-unmounted = "%mountpoint% not mounted"; # label-unmounted = "%mountpoint% not mounted";
# label-unmounted-foreground = colors.disabled; # label-unmounted-foreground = colors.disabled;
# }; # };
"module/mailcount" = {
type = "custom/script";
interval = 10;
format = "<label>";
exec = builtins.toString (pkgs.writeShellScript "mailcount.sh" ''
UNREAD=$(${pkgs.notmuch}/bin/notmuch count is:inbox and is:unread)
if [ $UNREAD = "0" ]; then
echo "%{T3}%{T-} "
else
echo "%{T2}%{T-} $UNREAD "
fi
'');
click-left =
"i3-msg 'exec --no-startup-id kitty --class aerc aerc'; sleep 0.15; i3-msg '[class=aerc] focus'";
};
"module/pulseaudio" = { "module/pulseaudio" = {
type = "internal/pulseaudio"; type = "internal/pulseaudio";
# format-volume-prefix = "VOL "; # format-volume-prefix = "VOL ";