From 058fc42c215355379d7ed082b0e30acad20bda52 Mon Sep 17 00:00:00 2001 From: Carlos Lobo <86011416+CarlosLoboxyz@users.noreply.github.com> Date: Sat, 25 Mar 2023 19:56:47 -0400 Subject: [PATCH] Add goimapnotify for push notifications --- README.md | 7 +++++++ bin/mw | 5 +++++ share/imapnotify-temp | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 share/imapnotify-temp diff --git a/README.md b/README.md index 5883014..5c3043a 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Specifically, this wizard: - `msmtp` - sends the email. - `pass` - safely encrypts passwords (required at install). - `ca-certificates` - required for SSL. Probably installed already. +- `goimapnotify` - required for push notifications. [Check here for reference](https://wiki.archlinux.org/title/Isync#With_imapnotify). **Note**: There's a chance of errors if you use a slow-release distro like Ubuntu, Debian, or Mint. If you get errors in `neomutt`, install the most @@ -133,6 +134,12 @@ To give you an example of the interface, here's an idea: - ctrl-b - open a menu to select a URL you want to open in your browser. - p - encrypt/sign your message (in compose view, before sending the email). +## Enable push notifications per mail +**Note**: Replace the `fulladdrs` with your actual email address. You have to do this for each new mail you want to setup instant notifications. +```bash +systemctl enable --user goimapnotify@fulladdrs.service +``` + ## Additional functionality - `pam-gnupg` - Automatically logs you into your GPG key on login, so you will diff --git a/bin/mw b/bin/mw index 2baa5f7..ab9c36d 100755 --- a/bin/mw +++ b/bin/mw @@ -12,12 +12,14 @@ msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_CACHE_HOME:-$HOME/.cache}/msmtp/msmtp.log" mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config" +imapnotify="${XDG_CONFIG_HOME:$HOME/.config}/imapnotify" mpoptemp="$muttshare/mpop-temp" mbsynctemp="$muttshare/mbsync-temp" mutttemp="$muttshare/mutt-temp" msmtptemp="$muttshare/msmtp-temp" onlinetemp="$muttshare/online-temp" notmuchtemp="$muttshare/notmuch-temp" +imapnotifytemp="$muttshare/imapnotify-temp" # With the use of templates, it's impossible to use parameter substitution. # Therefore, some default variables that might be otherwise overwritten are set # here. @@ -64,6 +66,8 @@ prepmbsync() { mkdir -p "${mbsyncrc%/*}" ; [ -f "$mbsyncrc" ] && echo >> "$mbsyn prepmpop() { mkdir -p "${mpoprc%/*}" ; envsubst < "$mpoptemp" >> "$mpoprc" ;} +prepimapnotify() { mkdir -p "${imapnotify%/*}" ; envsubst < "$imapnotifytemp" >> "$imapnotify/$fulladdr.conf" ;} + prepmutt() { mkdir -p "${muttrc%/*}" "$accdir" envsubst < "$mutttemp" > "$accdir/$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" @@ -90,6 +94,7 @@ getprofiles() { \ prepmsmtp prepmutt prepnotmuch + prepimapnotify } parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" diff --git a/share/imapnotify-temp b/share/imapnotify-temp new file mode 100644 index 0000000..a81cba2 --- /dev/null +++ b/share/imapnotify-temp @@ -0,0 +1,15 @@ +{ + "host": "$imap", + "port": $iport, + "tls": true, + "tlsOptions": { + "rejectUnauthorized": false + }, + "username": "$login", + "password": "", + "passwordCmd": "pass $passprefix$fulladdr", + "onNewMail": "mailsync", + "onNewMailPost": "", + "boxes": [ "INBOX" ] +} +