notify system added

This commit is contained in:
Luke Smith 2018-03-05 23:38:22 -07:00
parent 580cc963cb
commit 3049b27fa5
5 changed files with 48 additions and 10 deletions

View File

@ -15,6 +15,7 @@ The system takes an email and autodetect its server settings, generating a muttr
+ Multiple account management in mutt: jump from account to account with the `i` prefix in mutt: `i1`: first email account, `i5`: fifth, etc. + Multiple account management in mutt: jump from account to account with the `i` prefix in mutt: `i1`: first email account, `i5`: fifth, etc.
+ Easy movement to mail folders in mutt: `gi`: go to inbox, `gs` to sent mail, `ga` to archive, `gS` to spam, `gd` to drafts, etc. + Easy movement to mail folders in mutt: `gi`: go to inbox, `gs` to sent mail, `ga` to archive, `gS` to spam, `gd` to drafts, etc.
+ Some default controls and colors. This system is going to be integrated into my [public auto-rice script](https://larbs.xyz) so I want it to look pretty and be usable out the box. + Some default controls and colors. This system is going to be integrated into my [public auto-rice script](https://larbs.xyz) so I want it to look pretty and be usable out the box.
+ An optional autosync script that will smartly run offlineimap when connected to the internet at what interval you want and will notify you with a ding when new mail arrives.
### Will it work on my email? (95% yes) ### Will it work on my email? (95% yes)
@ -50,6 +51,8 @@ The automatically deployed configs will look for certain programs for certain ex
+ `mupdf` -- for viewing attached pdfs (`v` to view attachments, then select .pdf) + `mupdf` -- for viewing attached pdfs (`v` to view attachments, then select .pdf)
+ `notmuch` -- for mail searching and indexing set to `ctrl-f`. Be sure to run `notmuch setup`. Remember your mail is in `~/.mail/` when you configure notmuch. + `notmuch` -- for mail searching and indexing set to `ctrl-f`. Be sure to run `notmuch setup`. Remember your mail is in `~/.mail/` when you configure notmuch.
+ `w3m` and/or `w3mimg` -- for viewing images. Like .pdfs, view in the attachments menu. + `w3m` and/or `w3mimg` -- for viewing images. Like .pdfs, view in the attachments menu.
+ A cron manager if you want the autosync feature.
+ `mpv` if you want the autosync feature to notify you with a ding on new mail.
### "Wait? The script asks for my passwords?" ### "Wait? The script asks for my passwords?"

23
etc/mailsync.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
# This script will run offlineimap and check
# for new email if there is an internet connection.
#
# If it detects new mail, it uses mpv to play a
# notification sound: notify.opus
#
# I have this run as a cronjob every 5 minutes.
# Check for internet connection. Exit script if none.
ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit
# Get current number of new mail, then begin sync.
ori=$(find ~/.mail -wholename '*/new/*' | grep /new/ | grep -vi "spam\|trash\|junk" | wc -l)
offlineimap -o
# Output new new mail count.
new=$(find ~/.mail -wholename '*/new/*' | grep /new/ | grep -vi "spam\|trash\|junk" | wc -l)
# If new mail has grown, play a notification.
if [ "$new" -gt "$ori" ]; then
mpv --quiet ~/.config/mutt/etc/notify.opus
fi

BIN
etc/notify.opus Normal file

Binary file not shown.

View File

@ -2,6 +2,15 @@
muttdir="$HOME/.config/mutt/" muttdir="$HOME/.config/mutt/"
chooseSync() { (crontab -l && testSync) || dialog --msgbox "No cronjob manager detected. Please install one and return to enable automatic mailsyncing" 10 60 ;}
testSync() { (crontab -l | grep .config/mutt/etc/mailsync && removeSync) || addSync ;}
addSync() { min=$(dialog --inputbox "How many minutes should be between mail syncs?" 8 60 3>&1 1>&2 2>&3 3>&-)
(crontab -l; echo "*/$min * * * * /home/$(whoami)/.config/mutt/etc/mailsync.sh") | crontab - &&
dialog --msgbox "Cronjob successfully added. Remember you may need to restart or tell systemd/etc. to start your cron manager for this to take effect." 7 60 ;}
removeSync() { ((crontab -l | sed -e '/.config\/mutt\/etc\/mailsync/d') | crontab - >/dev/null) && dialog --msgbox "Cronjob successfully removed. To reactivate, select this option again." 6 60 ;}
changePassword() { \ changePassword() { \
gpgemail=$( dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your GPG key pair. This is NOT necessarily the email you want to configure." 10 60 3>&1 1>&2 2>&3 3>&- ) gpgemail=$( dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your GPG key pair. This is NOT necessarily the email you want to configure." 10 60 3>&1 1>&2 2>&3 3>&- )
dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the new password for the \"$1\" account." 10 60 2> /tmp/$1 dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the new password for the \"$1\" account." 10 60 2> /tmp/$1
@ -206,14 +215,15 @@ wipe () { rm $HOME/.offlineimaprc
while : ; while : ;
do do
choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" --nocancel \ choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" --nocancel \
--menu "What would you like to do?" 14 45 7 \ --menu "What would you like to do?" 16 45 8 \
0 "List all email accounts configured." \ 0 "List all email accounts configured." \
1 "Add an email account." \ 1 "Add an email account." \
2 "Auto-detect mailboxes for an account." \ 2 "Auto-detect mailboxes for an account." \
3 "Change an account's password." \ 3 "Enable/disable autosync." \
4 "Remove an email account." \ 4 "Change an account's password." \
5 "Remove all email accounts." \ 5 "Remove an email account." \
6 "Exit this wizard." \ 6 "Remove all email accounts." \
7 "Exit this wizard." \
3>&1 1>&2 2>&3 3>&1 ) 3>&1 1>&2 2>&3 3>&1 )
case $choice in case $choice in
@ -222,9 +232,10 @@ $(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g')
" 6 60;; " 6 60;;
1) chooseAdd;; 1) chooseAdd;;
2) detectWarning && chooseDetect ;; 2) detectWarning && chooseDetect ;;
3) inventory && for i in $userchoices; do changePassword $i ; done;; 3) chooseSync;;
4) inventory && for i in $userchoices; do removeAccount $i ; done;; 4) inventory && for i in $userchoices; do changePassword $i ; done;;
5) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;; 5) inventory && for i in $userchoices; do removeAccount $i ; done;;
6) clear && break ;; 6) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;;
7) clear && break ;;
esac esac
done done

3
muttrc
View File

@ -13,7 +13,8 @@ set timeout = "5"
set mail_check = "10" set mail_check = "10"
set mailcap_path = ~/.config/mutt/etc/mailcap set mailcap_path = ~/.config/mutt/etc/mailcap
set date_format="%m/%d %I:%M" set date_format="%m/%d %I:%M"
set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" set index_format="%2C %?X?A& ? %D %-15.15F %s (%-4.4c)"
#set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)"
set forward_format = "Fwd: %s" set forward_format = "Fwd: %s"
set markers = no set markers = no
set mark_old = no set mark_old = no