From faa0e1c5573143ccab8a9e683feb9c773b12cc5e Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Thu, 19 May 2016 10:48:28 +0100 Subject: [PATCH] Synchronize mail after quitting mutt --- offline_mail/.mutt/colors.mutt | 2 +- offline_mail/.mutt/mutt_with_mbsync.sh | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/offline_mail/.mutt/colors.mutt b/offline_mail/.mutt/colors.mutt index af89e6f..2c48840 100644 --- a/offline_mail/.mutt/colors.mutt +++ b/offline_mail/.mutt/colors.mutt @@ -1,4 +1,4 @@ -color index default red ~D color index green default ~Q +color index default red ~D color status white brightblack diff --git a/offline_mail/.mutt/mutt_with_mbsync.sh b/offline_mail/.mutt/mutt_with_mbsync.sh index 5b90e46..1b6c355 100755 --- a/offline_mail/.mutt/mutt_with_mbsync.sh +++ b/offline_mail/.mutt/mutt_with_mbsync.sh @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -PID="/var/run/user/1000/sync_maiboxes.pid" +PID="/var/run/user/1000/sync_mailboxes.pid" LOG="/home/max/.local/var/log/mutt_mbsync.log" touch $LOG @@ -8,25 +8,32 @@ clean_up() { kill -TERM $(cat $PID) rm $PID + + sync_mailboxes exit } trap clean_up SIGTERM SIGHUP SIGINT -sync_maiboxes() +sync_mailboxes() +{ + /usr/bin/mbsync -c /home/max/.mbsync/personal.mbsync -a >> $LOG 2>&1 + /usr/bin/mbsync -c /home/max/.mbsync/personal-gmail.mbsync -a >> $LOG 2>&1 + /usr/bin/mbsync -c /home/max/.mbsync/student.mbsync -a >> $LOG 2>&1 + /usr/bin/mbsync -c /home/max/.mbsync/musoft.mbsync -a >> $LOG 2>&1 +} + +sync_mailboxes_loop() { while true do - /usr/bin/mbsync -c /home/max/.mbsync/personal.mbsync -aq - /usr/bin/mbsync -c /home/max/.mbsync/personal-gmail.mbsync -aq - /usr/bin/mbsync -c /home/max/.mbsync/student.mbsync -aq - /usr/bin/mbsync -c /home/max/.mbsync/musoft.mbsync -aq + sync_mailboxes sleep 250 done } -sync_maiboxes& >> $LOG 2>&1 +sync_mailboxes_loop& >> $LOG 2>&1 echo $! > $PID /usr/bin/mutt -- 2.46.2