attempting email notifications

This commit is contained in:
Anish Lakhwara 2022-12-18 00:10:14 +10:00
parent ce410049c2
commit 115e66633a
5 changed files with 48 additions and 11 deletions

View file

@ -26,6 +26,8 @@ bspc config active_border_color "#181a23"
bspc config focused_border_color "#bd93f9" bspc config focused_border_color "#bd93f9"
bspc config presel_feedback_color "#bd93f9" bspc config presel_feedback_color "#bd93f9"
bspc config split_ratio 0.71
# Extra padding for polybar # Extra padding for polybar
bspc config -m primary top_padding 34 bspc config -m primary top_padding 34
bspc config -m primary bottom_padding 0 bspc config -m primary bottom_padding 0

View file

@ -35,7 +35,7 @@
origin = top-right origin = top-right
# Offset from the origin # Offset from the origin
offset = 12x28 offset = 22x28
# Scale factor. It is auto-detected if value is 0. # Scale factor. It is auto-detected if value is 0.
scale = 0 scale = 0
@ -182,7 +182,7 @@
hide_duplicate_count = true hide_duplicate_count = true
# Display indicators for URLs (U) and actions (A). # Display indicators for URLs (U) and actions (A).
show_indicators = no show_indicators = yes
### Icons ### ### Icons ###

View file

@ -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.file = "/etc/nixos/secrets/fastmail.age";
#age.secrets.fastmail.owner = "anish"; #age.secrets.fastmail.owner = "anish";
@ -13,6 +43,10 @@
frequency = "*:0/30"; frequency = "*:0/30";
#postExec = "${pkgs.notmuch}/bin/notmuch new"; #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; services.imapnotify.enable = true;
programs.mbsync.enable = true; programs.mbsync.enable = true;
programs.msmtp.enable = true; programs.msmtp.enable = true;
@ -23,6 +57,7 @@
image/png; feh %s image/png; feh %s
image/jpeg; feh %s image/jpeg; feh %s
''; '';
programs.neomutt = { programs.neomutt = {
enable = true; enable = true;
extraConfig = '' extraConfig = ''
@ -31,9 +66,9 @@
set editor = "nvim +':set textwidth=0'" set editor = "nvim +':set textwidth=0'"
#set virtual_spoolfile=yes #set virtual_spoolfile=yes
set folder="~/Mail/anish" set folder="~/Maildir/anish"
set mbox_type = Maildir 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 ## Folder with emails
#set folder = "~/Mail/anish" #set folder = "~/Mail/anish"
@ -269,14 +304,10 @@
extraConfig.local.subFolders = "Verbatim"; extraConfig.local.subFolders = "Verbatim";
}; };
imapnotify = { imapnotify = {
enable = true; enable = false;
boxes = [ "Inbox" ]; boxes = [ "Inbox" ];
onNotify = "${pkgs.isync}/bin/mbsync anish && ${pkgs.notmuch}/bin/notmuch index"; onNotify = "${pkgs.isync}/bin/mbsync anish && ${pkgs.notmuch}/bin/notmuch index";
onNotifyPost = { onNotifyPost = "${pkgs.libnotify}/bin/notify-send -a mail 'email: new in %s'";
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'";
};
}; };
msmtp.enable = true; msmtp.enable = true;
msmtp.extraConfig = { msmtp.extraConfig = {

View file

@ -0,0 +1 @@
{"boxes":["Inbox"],"host":"imap.fastmail.com","onNewMail":"/nix/store/pmvvqwrsyv6ah0x8c82hgkddas5f9ajb-isync-1.4.4/bin/mbsync anish && /nix/store/wyi8a02kk3vh5y7qhdkfzyibb1yl0xc1-notmuch-0.37/bin/notmuch index","onNewMailPost":{"mail":"/nix/store/q360zpybna4djr4kjhjg6hmkk3vj7pjf-libnotify-0.8.1/bin/notify-send -a mail 'email: new in %s'"},"passwordCmd":"'/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin/cat' '/run/agenix/fastmail'","port":993,"tls":true,"username":"anish@lakhwara.com"}

View file

@ -14,6 +14,9 @@ in
"mossnet.age".publicKeys = allUserKeys; "mossnet.age".publicKeys = allUserKeys;
"curve-wg.age".publicKeys = curve; "curve-wg.age".publicKeys = curve;
"box-wg.age".publicKeys = [ mossnet ]; "box-wg.age".publicKeys = [ mossnet ];
"wallabag-password.age".publicKeys = [ mossnet ];
"wallabag-secret.age".publicKeys = [ mossnet ];
"borg-password.age".publicKeys = systemOnly; "borg-password.age".publicKeys = systemOnly;
"freshrss-dbpass.age".publicKeys = [ helix ]; "freshrss-dbpass.age".publicKeys = [ helix ];
"synapse-config.age".publicKeys = [ lituus ]; "synapse-config.age".publicKeys = [ lituus ];