Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

46 wiersze
1.6 KiB

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