From 115e66633a46bf061311b5a2ad8fabc8e472929c Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Sun, 18 Dec 2022 00:10:14 +1000 Subject: [PATCH] attempting email notifications --- home/profiles/desktop/bspwmrc | 2 + home/profiles/desktop/dunstrc | 4 +- home/profiles/email/default.nix | 49 +++++++++++++++---- .../email/imapnotify-anish-config.json | 1 + secrets/secrets.nix | 3 ++ 5 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 home/profiles/email/imapnotify-anish-config.json diff --git a/home/profiles/desktop/bspwmrc b/home/profiles/desktop/bspwmrc index 5d8505ff..d942f4e5 100755 --- a/home/profiles/desktop/bspwmrc +++ b/home/profiles/desktop/bspwmrc @@ -26,6 +26,8 @@ bspc config active_border_color "#181a23" bspc config focused_border_color "#bd93f9" bspc config presel_feedback_color "#bd93f9" +bspc config split_ratio 0.71 + # Extra padding for polybar bspc config -m primary top_padding 34 bspc config -m primary bottom_padding 0 diff --git a/home/profiles/desktop/dunstrc b/home/profiles/desktop/dunstrc index e25190a3..91d8fe16 100644 --- a/home/profiles/desktop/dunstrc +++ b/home/profiles/desktop/dunstrc @@ -35,7 +35,7 @@ origin = top-right # Offset from the origin - offset = 12x28 + offset = 22x28 # Scale factor. It is auto-detected if value is 0. scale = 0 @@ -182,7 +182,7 @@ hide_duplicate_count = true # Display indicators for URLs (U) and actions (A). - show_indicators = no + show_indicators = yes ### Icons ### diff --git a/home/profiles/email/default.nix b/home/profiles/email/default.nix index d6fc7104..35fc9d10 100644 --- a/home/profiles/email/default.nix +++ b/home/profiles/email/default.nix @@ -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 = { diff --git a/home/profiles/email/imapnotify-anish-config.json b/home/profiles/email/imapnotify-anish-config.json new file mode 100644 index 00000000..5b900b0e --- /dev/null +++ b/home/profiles/email/imapnotify-anish-config.json @@ -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"} diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 1471ad7f..e9de2027 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -14,6 +14,9 @@ in "mossnet.age".publicKeys = allUserKeys; "curve-wg.age".publicKeys = curve; "box-wg.age".publicKeys = [ mossnet ]; + "wallabag-password.age".publicKeys = [ mossnet ]; + "wallabag-secret.age".publicKeys = [ mossnet ]; + "borg-password.age".publicKeys = systemOnly; "freshrss-dbpass.age".publicKeys = [ helix ]; "synapse-config.age".publicKeys = [ lituus ];