forked from colonelpanic/dotfiles
Be smarter about whether or not to actually update the index. Start
emacs/open frame if its not open when notifications are clicked.
This commit is contained in:
parent
9f4c38b24f
commit
e97f439674
@ -1,4 +1,4 @@
|
|||||||
MAILDIR="$HOME/Mail"
|
MAILDIR="$HOME/Mail/INBOX/"
|
||||||
SYNC_STAMP="$HOME/.mail-sync"
|
SYNC_STAMP="$HOME/.mail-sync"
|
||||||
APP_ICON="$(dotfiles_directory)/resources/gmail_logo.png"
|
APP_ICON="$(dotfiles_directory)/resources/gmail_logo.png"
|
||||||
SYNC_COMMAND="offlineimap -f INBOX"
|
SYNC_COMMAND="offlineimap -f INBOX"
|
||||||
@ -8,7 +8,7 @@ function mu4e_alert_for_filename {
|
|||||||
local title="$(echo $message | grep From | sed 's/From: //')"
|
local title="$(echo $message | grep From | sed 's/From: //')"
|
||||||
local subject="$(echo $message | grep Subject | sed 's/Subject: //')"
|
local subject="$(echo $message | grep Subject | sed 's/Subject: //')"
|
||||||
local mu4e_message_id="$(mu4e_get_msg_id_from_file $1)"
|
local mu4e_message_id="$(mu4e_get_msg_id_from_file $1)"
|
||||||
local view_file_command="$(which zsh) -c \"refresh_config && mu4e_view_message $mu4e_message_id\""
|
local view_file_command="$(which zsh) -c \"refresh_config && emacs_make_frame_if_none_exists && mu4e_view_message $mu4e_message_id\""
|
||||||
local app_icon_argument=''
|
local app_icon_argument=''
|
||||||
test -e "$APP_ICON" && app_icon_argument="-appIcon '$APP_ICON'"
|
test -e "$APP_ICON" && app_icon_argument="-appIcon '$APP_ICON'"
|
||||||
reattach-to-user-namespace $(which terminal-notifier) \
|
reattach-to-user-namespace $(which terminal-notifier) \
|
||||||
@ -21,8 +21,12 @@ function mu4e_alert_for_filename {
|
|||||||
|
|
||||||
function mu4e_update_mail {
|
function mu4e_update_mail {
|
||||||
eval $SYNC_COMMAND
|
eval $SYNC_COMMAND
|
||||||
|
if test -z "$(find "$MAILDIR" -cnewer "$SYNC_STAMP" -a -type f)"; then
|
||||||
|
echo "$(date) - No new messages, skipping alerting and indexing."
|
||||||
|
else
|
||||||
mu4e_update_index
|
mu4e_update_index
|
||||||
mu4e_alerts
|
mu4e_alerts
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function mu4e_update_index {
|
function mu4e_update_index {
|
||||||
@ -32,7 +36,7 @@ function mu4e_update_index {
|
|||||||
function mu4e_alerts {
|
function mu4e_alerts {
|
||||||
test -e $SYNC_STAMP || touch $SYNC_STAMP
|
test -e $SYNC_STAMP || touch $SYNC_STAMP
|
||||||
touch "${SYNC_STAMP}.in-progress"
|
touch "${SYNC_STAMP}.in-progress"
|
||||||
for f in $(find "$MAILDIR/INBOX" -cnewer "$SYNC_STAMP" -a -type f); do
|
for f in $(find "$MAILDIR" -cnewer "$SYNC_STAMP" -a -type f); do
|
||||||
mu4e_alert_for_filename $f
|
mu4e_alert_for_filename $f
|
||||||
done
|
done
|
||||||
mv "${SYNC_STAMP}.in-progress" $SYNC_STAMP
|
mv "${SYNC_STAMP}.in-progress" $SYNC_STAMP
|
||||||
|
Loading…
Reference in New Issue
Block a user