From 755a4d9d91e22c05cd3dfa50dff63794a232d0d3 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Sat, 20 Jul 2019 17:25:08 +0200 Subject: [PATCH] Improve checkmail script: add options --- dotfiles/systemd.org | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/dotfiles/systemd.org b/dotfiles/systemd.org index d3ae8de..bea7b21 100644 --- a/dotfiles/systemd.org +++ b/dotfiles/systemd.org @@ -75,7 +75,7 @@ [Service] Type=oneshot - ExecStart=%h/scripts/checkmail.sh + ExecStart=%h/scripts/checkmail.sh -q -v #+END_SRC ** Timer @@ -112,6 +112,17 @@ :END: #+begin_src bash + while [ -n "$1" ]; do # while loop starts + case "$1" in + -a) opt_mbsync_all='--all' ;; # Check All inboxes + -v) opt_verbose='--verbose' ;; # Verbose + -q) opt_quiet='--quiet' ;; # Quiet + *) echo "Option $1 not recognized" ;; # In case you typed a different option + esac + shift + done + + # ============================================================= # Count number of mails gmail_old="$(ls ~/.mail/gmail/Inbox/new | wc -l)" @@ -121,13 +132,7 @@ # ============================================================= # Retreive mails - if [ -z "$1" ]; then - # No argument => just check Inbox - mbsync gmail-Home esrf-Home ulg-Home - elif [ "$1" = "all" ]; then - # Synchronize all mails - mbsync -a - fi + mbsync $opt_all $opt_verbose gmail-Home esrf-Home ulg-Home # ============================================================= # ============================================================= @@ -153,7 +158,7 @@ # ============================================================= # Indexation and Tags # notmuch new - mu index --maildir=~/.mail --quiet + mu index --maildir=~/.mail $opt_verbose $opt_quiet # Update on Emacs # if [ "$(($new-$old))" -gt 0 ]; then # emacsclient --eval '(mu4e-update-index)'; @@ -176,7 +181,7 @@ [Service] Type=oneshot - ExecStart=%h/scripts/checkmail.sh all + ExecStart=%h/scripts/checkmail.sh -a -q -v #+END_SRC ** Timer