25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
746 B

  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.
  10. ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit
  11. # Get current number of new mail, then begin sync.
  12. ori=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l)
  13. offlineimap -o
  14. # Recount new mail.
  15. new=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l)
  16. # If new mail has grown, play a notification.
  17. if [ "$new" -gt "$ori" ]; then
  18. mpv --quiet ~/.config/mutt/etc/notify.opus
  19. fi