attempting email notifications
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
{ pkgs, ... }:
|
||||
{ config, pkgs, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
safeName = lib.replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ];
|
||||
imapnotifyAccounts =
|
||||
filter (a: a.imapnotify.enable) (attrValues config.accounts.email.accounts);
|
||||
genAccountUnit = account:
|
||||
let name = safeName account.name;
|
||||
in
|
||||
{
|
||||
name = "imapnotify-${name}-mine";
|
||||
value = {
|
||||
Unit = { Description = "imapnotify for ${name}"; };
|
||||
|
||||
Service = {
|
||||
ExecStart = "${pkgs.goimapnotify}/bin/goimapnotify -conf /nix/store/6030i9xdga98l2zyqarrqv5mrjynwm3i-imapnotify-anish-config.json"; # TODO horrible hard coded config location
|
||||
Restart = "always";
|
||||
RestartSec = 30;
|
||||
Type = "simple";
|
||||
# this is why we're overriding this stupid thing
|
||||
# We need dbus for notify-send on systemd
|
||||
Environment = [
|
||||
"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"
|
||||
"NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/default/config"
|
||||
];
|
||||
};
|
||||
|
||||
Install = { WantedBy = [ "default.target" ]; };
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
#age.secrets.fastmail.file = "/etc/nixos/secrets/fastmail.age";
|
||||
#age.secrets.fastmail.owner = "anish";
|
||||
@@ -13,6 +43,10 @@
|
||||
frequency = "*:0/30";
|
||||
#postExec = "${pkgs.notmuch}/bin/notmuch new";
|
||||
};
|
||||
|
||||
# call our stupid way of overriding the imapnotify service
|
||||
systemd.user.services = listToAttrs (map genAccountUnit [{ name = "anish"; }]);
|
||||
|
||||
services.imapnotify.enable = true;
|
||||
programs.mbsync.enable = true;
|
||||
programs.msmtp.enable = true;
|
||||
@@ -23,6 +57,7 @@
|
||||
image/png; feh %s
|
||||
image/jpeg; feh %s
|
||||
'';
|
||||
|
||||
programs.neomutt = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
@@ -31,9 +66,9 @@
|
||||
set editor = "nvim +':set textwidth=0'"
|
||||
|
||||
#set virtual_spoolfile=yes
|
||||
set folder="~/Mail/anish"
|
||||
set folder="~/Maildir/anish"
|
||||
set mbox_type = Maildir
|
||||
mailboxes `find ~/Mail/anish/* -maxdepth 0 -type d | grep -v "Trash\|Spam\|tmp\|new\|cur" | sed 's|/home/anish/Mail/anish|=\"|g' | sed 's|$|\"|g' | tr '\n' ' '`
|
||||
mailboxes `find ~/Maildir/anish/* -maxdepth 0 -type d | grep -v "Trash\|Spam\|tmp\|new\|cur" | sed 's|/home/anish/Maildir/anish|=\"|g' | sed 's|$|\"|g' | tr '\n' ' '`
|
||||
|
||||
## Folder with emails
|
||||
#set folder = "~/Mail/anish"
|
||||
@@ -269,14 +304,10 @@
|
||||
extraConfig.local.subFolders = "Verbatim";
|
||||
};
|
||||
imapnotify = {
|
||||
enable = true;
|
||||
enable = false;
|
||||
boxes = [ "Inbox" ];
|
||||
onNotify = "${pkgs.isync}/bin/mbsync anish && ${pkgs.notmuch}/bin/notmuch index";
|
||||
onNotifyPost = {
|
||||
mail = "${pkgs.libnotify}/bin/notify-send -a mail 'email: new in %s'";
|
||||
#update = "${pkgs.libnotify}/bin/notify-send -a mail 'email: update %s'";
|
||||
#expunge = "${pkgs.libnotify}/bin/notify-send -a mail 'email: expunge %s'";
|
||||
};
|
||||
onNotifyPost = "${pkgs.libnotify}/bin/notify-send -a mail 'email: new in %s'";
|
||||
};
|
||||
msmtp.enable = true;
|
||||
msmtp.extraConfig = {
|
||||
|
||||
Reference in New Issue
Block a user