diff options
author | Luke Smith <luke@lukesmith.xyz> | 2019-02-21 10:14:17 -0500 |
---|---|---|
committer | Luke Smith <luke@lukesmith.xyz> | 2019-02-21 10:14:17 -0500 |
commit | 03279ea318805b3fa7545f01385485e8053daea5 (patch) | |
tree | b015842b634f78d2f0f3a275ef561a75c153dab8 /bin | |
parent | f2dcd92c30d4d595a3daa4f8e977ffb967839b69 (diff) |
rewrite underway
Diffstat (limited to 'bin')
-rw-r--r-- | bin/email.gif | bin | 0 -> 7545 bytes | |||
-rwxr-xr-x | bin/getmuttpass | 5 | ||||
-rwxr-xr-x | bin/imappwd.py | 11 | ||||
-rw-r--r-- | bin/mailcap | 7 | ||||
-rwxr-xr-x | bin/mailsync | 43 | ||||
-rwxr-xr-x | bin/muttimage | 8 | ||||
-rw-r--r-- | bin/notify.opus | bin | 0 -> 28900 bytes | |||
-rwxr-xr-x | bin/openfile | 9 |
8 files changed, 83 insertions, 0 deletions
diff --git a/bin/email.gif b/bin/email.gif Binary files differnew file mode 100644 index 0000000..1ed63cf --- /dev/null +++ b/bin/email.gif diff --git a/bin/getmuttpass b/bin/getmuttpass new file mode 100755 index 0000000..15a1d55 --- /dev/null +++ b/bin/getmuttpass @@ -0,0 +1,5 @@ +#!/bin/bash +GPG="gpg"; command -v gpg >/dev/null || GPG="gpg2" +pass=$(printf '%q' "$("$GPG" --decrypt --quiet ~/.local/share/muttwizard/$1.gpg)") +echo "set smtp_pass=\"$pass\"" +echo "set imap_pass=\"$pass\"" diff --git a/bin/imappwd.py b/bin/imappwd.py new file mode 100755 index 0000000..9b25fcc --- /dev/null +++ b/bin/imappwd.py @@ -0,0 +1,11 @@ +import os.path +import subprocess +home = os.path.expanduser("~") +def mailpasswd(acct): + acct = os.path.basename(acct) + path = "%s/.local/share/muttwizard/%s.gpg" % (home,acct) + args = ["gpg2", "--use-agent", "--quiet", "--batch", "-d", path] + try: + return subprocess.check_output(args).strip().decode('UTF-8') + except subprocess.CalledProcessError: + return "" diff --git a/bin/mailcap b/bin/mailcap new file mode 100644 index 0000000..6dcca4d --- /dev/null +++ b/bin/mailcap @@ -0,0 +1,7 @@ +text/plain; vim %s ; +text/html; ~/.config/mutt/bin/openfile %s ; +text/html; w3m -I %{charset} -T text/html; copiousoutput; +image/*; ~/.config/mutt/bin/muttimage %s ; copiousoutput +video/*; setsid mpv --quiet %s &; copiousoutput +application/pdf; ~/.config/mutt/bin/openfile %s ; +application/pgp-encrypted; gpg -d '%s'; copiousoutput; diff --git a/bin/mailsync b/bin/mailsync new file mode 100755 index 0000000..629f044 --- /dev/null +++ b/bin/mailsync @@ -0,0 +1,43 @@ +#!/usr/bin/env 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. + +export DISPLAY=:0.0 + +# Checks for internet connection and set notification script. +ping -q -c 1 1.1.1.1 > /dev/null || exit +# Settings are different for MacOS (Darwin) systems. +if [ "$(uname)" = "Darwin" ] +then + notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} +else + notify() { mpv --really-quiet ~/.config/mutt/bin/notify.opus & pgrep -x dunst && notify-send -i ~/.config/mutt/bin/email.gif "$2 new mail(s) in \`$1\` account." ;} +fi + +echo " 🔃" > /tmp/imapsyncicon +pkill -RTMIN+12 i3blocks + +# Run offlineimap. You can feed this script different settings. +offlineimap -o "$@" +rm -f /tmp/imapsyncicon +pkill -RTMIN+12 i3blocks + +# Check all accounts/mailboxes for new mail. Notify if there is new content. +for account in $(ls ~/.local/share/mail) +do + #List unread messages newer than last mailsync and count them + newcount=$(find ~/.mail/"$account"/INBOX/new/ -type f -newer ~/.config/mutt/bin/.mailsynclastrun 2> /dev/null | wc -l) + if [ "$newcount" -gt "0" ] + then + notify "$account" "$newcount" & + fi +done +notmuch new + +#Create a touch file that indicates the time of the last run of mailsync +touch ~/.config/mutt/bin/.mailsynclastrun diff --git a/bin/muttimage b/bin/muttimage new file mode 100755 index 0000000..b67de83 --- /dev/null +++ b/bin/muttimage @@ -0,0 +1,8 @@ +#! /bin/sh + +#### Determine size of Terminal +height=`stty size | awk 'BEGIN {FS = " "} {print $1;}'` +width=`stty size | awk 'BEGIN {FS = " "} {print $2;}'` + +### Display Image / offset with mutt bar +echo -e "2;3;\n0;1;210;20;$((width*7-250));$((height*14-100));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay & diff --git a/bin/notify.opus b/bin/notify.opus Binary files differnew file mode 100644 index 0000000..a76ce32 --- /dev/null +++ b/bin/notify.opus diff --git a/bin/openfile b/bin/openfile new file mode 100755 index 0000000..fdc0e5f --- /dev/null +++ b/bin/openfile @@ -0,0 +1,9 @@ +#!/bin/sh +# Helps open a file with xdg-open from mutt in a external program without weird side effects. + +base=$(basename "$1") +ext="${base##*.}" +file=$(mktemp -u --suffix=".$ext") +rm -f "$file" +cp "$1" "$file" +setsid xdg-open "$file" >/dev/null 2>&1 & |