Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

mailsync.sh 1.4 KiB

6 anos atrás
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env 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. export DISPLAY=:0.0
  10. # Checks for internet connection and set notification script.
  11. ping -q -c 1 1.1.1.1 > /dev/null || exit
  12. # Settings are different for MacOS (Darwin) systems.
  13. if [ "$(uname)" = "Darwin" ]
  14. then
  15. notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
  16. else
  17. notify() { mpv --really-quiet ~/.config/mutt/etc/notify.opus & pgrep -x dunst && notify-send -i ~/.config/mutt/etc/email.gif "$2 new mail(s) in \`$1\` account." ;}
  18. fi
  19. echo " 🔃" > ~/.config/mutt/.dl
  20. pkill -RTMIN+12 i3blocks
  21. # Run offlineimap. You can feed this script different settings.
  22. offlineimap -o "$@"
  23. rm -f ~/.config/mutt/.dl
  24. pkill -RTMIN+12 i3blocks
  25. # Check all accounts/mailboxes for new mail. Notify if there is new content.
  26. for account in $(ls ~/.mail)
  27. do
  28. #List unread messages newer than last mailsync and count them
  29. newcount=$(find ~/.mail/"$account"/INBOX/new/ -type f -newer ~/.config/mutt/etc/.mailsynclastrun 2> /dev/null | wc -l)
  30. if [ "$newcount" -gt "0" ]
  31. then
  32. notify "$account" "$newcount" &
  33. fi
  34. done
  35. notmuch new
  36. #Create a touch file that indicates the time of the last run of mailsync
  37. touch ~/.config/mutt/etc/.mailsynclastrun