Improve checkmail script: add options

This commit is contained in:
Thomas Dehaeze 2019-07-20 17:25:08 +02:00
parent 9edeeb48d1
commit 755a4d9d91

View File

@ -75,7 +75,7 @@
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=%h/scripts/checkmail.sh ExecStart=%h/scripts/checkmail.sh -q -v
#+END_SRC #+END_SRC
** Timer ** Timer
@ -112,6 +112,17 @@
:END: :END:
#+begin_src bash #+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 # Count number of mails
gmail_old="$(ls ~/.mail/gmail/Inbox/new | wc -l)" gmail_old="$(ls ~/.mail/gmail/Inbox/new | wc -l)"
@ -121,13 +132,7 @@
# ============================================================= # =============================================================
# Retreive mails # Retreive mails
if [ -z "$1" ]; then mbsync $opt_all $opt_verbose gmail-Home esrf-Home ulg-Home
# No argument => just check Inbox
mbsync gmail-Home esrf-Home ulg-Home
elif [ "$1" = "all" ]; then
# Synchronize all mails
mbsync -a
fi
# ============================================================= # =============================================================
# ============================================================= # =============================================================
@ -153,7 +158,7 @@
# ============================================================= # =============================================================
# Indexation and Tags # Indexation and Tags
# notmuch new # notmuch new
mu index --maildir=~/.mail --quiet mu index --maildir=~/.mail $opt_verbose $opt_quiet
# Update on Emacs # Update on Emacs
# if [ "$(($new-$old))" -gt 0 ]; then # if [ "$(($new-$old))" -gt 0 ]; then
# emacsclient --eval '(mu4e-update-index)'; # emacsclient --eval '(mu4e-update-index)';
@ -176,7 +181,7 @@
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=%h/scripts/checkmail.sh all ExecStart=%h/scripts/checkmail.sh -a -q -v
#+END_SRC #+END_SRC
** Timer ** Timer