Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

mailsync.sh 898 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. # This script will run offlineimap and check
  3. # for new email if there is an internet connection.
  4. #
  5. # If it detects new mail, it uses mpv to play a
  6. # notification sound: notify.opus
  7. #
  8. # I have this run as a cronjob every 5 minutes.
  9. # Check for internet connection. Exit script if none. (timeout in mac is `-t`)
  10. if [ "$(uname)" == "Darwin" ]
  11. then
  12. ping -q -t 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit
  13. else
  14. ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit
  15. fi
  16. # Get current number of new mail, then begin sync.
  17. ori=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l)
  18. offlineimap -o "$@"
  19. # Recount new mail.
  20. new=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l)
  21. # If new mail has grown, play a notification.
  22. if [ "$new" -gt "$ori" ]; then
  23. mpv --quiet ~/.config/mutt/etc/notify.opus
  24. fi