12 Commits

Author SHA1 Message Date
  Luke Smith 8e66fcb58a
Merge branch 'master' of github.com:LukeSmithxyz/mutt-wizard 2 years ago
  Luke Smith c88994e730
decrease gnuisms 2 years ago
  Luke Smith a1a6b60217
Merge pull request #719 from epsilon-0/master 2 years ago
  Luke Smith 4e92252dc2
Merge branch 'master' into master 2 years ago
  Luke Smith e8458ace20
fix #691, fix #689, fix #690 2 years ago
  Luke Smith c0762da3a7
Merge branch 'master' of github.com:LukeSmithxyz/mutt-wizard 2 years ago
  Luke Smith 8d177222d6
don't show message info anymore 2 years ago
  Luke Smith 0997033ba3
Merge pull request #758 from Benjamin-Davies/add-uclive 2 years ago
  Luke Smith f845e11fe2
fix #745, avoid incompatibility 2 years ago
  Benjamin-Davies 2ef58a8e43
Add uclive.ac.nz domains 2 years ago
  Aisha Tammy 2a50561834
set mindepth to 1 and move sort to after sed 2 years ago
  Aisha Tammy 2cb2fa0345
allow dynamically loading available mailboxes 2 years ago
5 changed files with 50 additions and 29 deletions
Split View
  1. +2
    -2
      Makefile
  2. +3
    -14
      bin/mailsync
  3. +6
    -13
      bin/mw
  4. +2
    -0
      share/domains.csv
  5. +37
    -0
      share/unbind.muttrc

+ 2
- 2
Makefile View File

@@ -14,8 +14,8 @@ install:
chmod 755 $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/bin/openfile
mkdir -p $(DESTDIR)$(PREFIX)/share/mutt-wizard
chmod 755 $(DESTDIR)$(PREFIX)/share/mutt-wizard
cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard
chmod 644 $(DESTDIR)$(PREFIX)/share/mutt-wizard/mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard/domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc
cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc share/unbind.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard
chmod 644 $(DESTDIR)$(PREFIX)/share/mutt-wizard/mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard/domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard/unbind.muttrc
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
cp -f mw.1 $(DESTDIR)$(MANPREFIX)/man1/mw.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/mw.1


+ 3
- 14
bin/mailsync View File

@@ -14,7 +14,7 @@
# Run only if user logged in (prevent cron errors)
pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;}
# Run only if not already running in other instance
pidof mbsync >/dev/null && { echo "mbsync is already running."; exit ;}
pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;}

# First, we have to get the right variables for the mbsync file, the pass
# archive, notmuch and the GPG home. This is done by searching common profile
@@ -25,7 +25,7 @@ eval "$(grep -h -- \
"$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \
"$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" "$HOME/.pam_environment" 2>/dev/null)"

export GPG_TTY=$TTY
export GPG_TTY="$(tty)"

[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc"

@@ -33,7 +33,6 @@ export GPG_TTY=$TTY
case "$(uname)" in
Darwin)
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\"" ;}
;;
*)
case "$(readlink -f /sbin/init)" in
@@ -46,10 +45,6 @@ case "$(uname)" in
export DISPLAY=$x
notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account."
done ;}
messageinfo() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do
export DISPLAY=$x
notify-send --app-name="mutt-wizard" "📧$from:" "$subject"
done ;}
;;
esac

@@ -67,13 +62,7 @@ syncandnotify() {
-type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2> /dev/null)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
case 1 in
$((newcount > 5)) ) notify "$acc" "$newcount" ;;
$((newcount > 0)) ) for file in $new; do
# Extract subject and sender from mail.
from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
messageinfo &
done ;;
$((newcount > 0)) ) notify "$acc" "$newcount" ;;
esac
}



+ 6
- 13
bin/mw View File

@@ -101,16 +101,8 @@ set header_cache = $cachedir/$fulladdr/headers
set message_cachedir = $cachedir/$fulladdr/bodies
set mbox_type = Maildir
set hostname = \"$hostname\"
source $muttshare/unbind.muttrc
$extra

bind index,pager gg noop
bind index,pager g noop
bind index,pager M noop
bind index,pager C noop
bind index gg first-entry
unmailboxes *
unalternates *
unset signature
$synccmd
" > "$accdir/$idnum-$fulladdr.muttrc"

@@ -137,7 +129,7 @@ set ssl_force_tls = yes"
pop) synccmd="macro index o \"<shell-escape>mpop $fulladdr<enter>\" \"run mpop to get $fulladdr's mail\""
folder="$maildir/$fulladdr"
prepmpop ;;
*) synccmd="macro index o \"<shell-escape>mbsync $fulladdr<enter>\" \"run mbsync to sync $fulladdr\""
*) synccmd="macro index o \"<shell-escape>mw -y $fulladdr<enter>\" \"run mbsync to sync $fulladdr\""
folder="$maildir/$fulladdr"
prepmbsync ;;
esac
@@ -232,11 +224,12 @@ getboxes() { if [ -n "${force+x}" ] ; then
else
info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")"
[ -z "$info" ] && echo "Log-on not successful." && return 1
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' ')"
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '
')"
fi
[ "$type" = "pop" ] && mailboxes="INBOX"
getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done
toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )"
getaccounts; for x in 1 2 3 4 5 6 7 8 9; do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done
toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`"
IFS='
'
for x in $mailboxes; do


+ 2
- 0
share/domains.csv View File

@@ -50,6 +50,7 @@ canaglie.net,mail.autistici.org,993,smtp.autistici.org,465
canaglie.org,mail.autistici.org,993,smtp.autistici.org,465
carleton.ca,imap-mail.outlook.com,993,smtp-mail.outlook.com,587
cash4u.com,imap.mail.com,993,smtp.mail.com,587
cedars.xyz,mail.cedars.xyz,993,mail.cedars.xyz,465
ceng.metu.edu.tr,imap.ceng.metu.edu.tr,993,mailhost.ceng.metu.edu.tr,587
cheerful.com,imap.mail.com,993,smtp.mail.com,587
chef.net,imap.mail.com,993,smtp.mail.com,587
@@ -283,6 +284,7 @@ txstate.edu,outlook.office365.com,993,smtp.office365.com,587
ua.pt,outlook.office365.com,993,mail.ua.pt,25
uach.mx,imap.gmail.com,993,smtp.gmail.com,587
ucdavis.edu,imap.gmail.com,993,smtp.gmail.com,587
uclive.ac.nz,outlook.office365.com,993,smtp.office365.com,587
ucsb.edu,imap.gmail.com,993,smtp.gmail.com,587
ucsc.edu,imap.gmail.com,993,smtp.gmail.com,587
uni-duesseldorf.de,mail.hhu.de,993,mail.hhu.de,465


+ 37
- 0
share/unbind.muttrc View File

@@ -0,0 +1,37 @@
# vim: filetype=neomuttrc

# This is an embarrassing and hacky file that unbinds a bunch of binds between
# switching accounts. It is called each time an account is changed.

bind index,pager gi noop
bind index,pager gs noop
bind index,pager gd noop
bind index,pager ga noop
bind index,pager gS noop
bind index,pager gj noop
bind index,pager gt noop
bind index,pager Mi noop
bind index,pager Ms noop
bind index,pager Md noop
bind index,pager Ma noop
bind index,pager MS noop
bind index,pager Mj noop
bind index,pager Mt noop
bind index,pager Ci noop
bind index,pager Cs noop
bind index,pager Cd noop
bind index,pager Ca noop
bind index,pager CS noop
bind index,pager Cj noop
bind index,pager Ct noop
bind index,pager gg noop
bind index,pager g noop
bind index,pager M noop
bind index,pager C noop
unset hostname
unmy_hdr Organization
unmailboxes *
unalternates *
unset signature

bind index gg first-entry

Loading…
Cancel
Save