summary refs log tree commit diff
path: root/bin/hibiki
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hibiki')
-rwxr-xr-xbin/hibiki/mailsync13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/hibiki/mailsync b/bin/hibiki/mailsync
index 66d6164..b248215 100755
--- a/bin/hibiki/mailsync
+++ b/bin/hibiki/mailsync
@@ -37,7 +37,6 @@ notifysend() {
 	local ico
 	shift 2
 
-	set -x
 	if ! printf "%s" "$*" | grep -- "-i" >/dev/null; then
 		ico="📨 "
 	fi
@@ -47,7 +46,6 @@ notifysend() {
 		-a mailsync \
 		-c audible \
 		"${ico:-}${summary}" "${body}"
-	set +x
 }
 
 decode() {
@@ -88,7 +86,7 @@ list_msg() {
 	# fi
 }
 
-notify() {
+run_notify() {
 	local acct=$1
 	local new_mail
 
@@ -107,7 +105,7 @@ notify() {
 	fi
 }
 
-sync() {
+run_sync() {
 	local acct=$1
 
 	# exit if we're already running
@@ -132,6 +130,9 @@ sync() {
 		--object-path /org/freedesktop/Notifications \
 		--method org.freedesktop.Notifications.CloseNotification \
 		"$id" >/dev/null
+
+	# index new messages
+	command notmuch >/dev/null && notmuch new
 }
 
 # only list new mail, don't sync
@@ -146,8 +147,8 @@ for acct in "${accounts[@]}"; do
 			list_msg "${list}" "${acct}"
 			exit 0 # exit ()& subshell
 		fi
-		sync "${acct}"
-		notify "${acct}"
+		run_sync "${acct}"
+		run_notify "${acct}"
 	) &
 done