newsboat-notification.sh 683 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. if ! [ -s ~/.cache/.rss.cache ]; then
  3. echo "0" > ~/.cache/.rss.cache
  4. fi
  5. critical_run=$(pgrep "^newsboat$")
  6. while [ -n "$critical_run" ]; do
  7. sleep 20s
  8. critical_run=$(pgrep "^newsboat$")
  9. done
  10. notifications=$(newsboat -x reload -x print-unread | grep -Eo '[0-9]+')
  11. if [ "$notifications" -eq 0 ]; then
  12. echo "0" | tee ~/.cache/.rss.cache
  13. exit 0;
  14. fi
  15. previous=$(cat ~/.cache/.rss.cache)
  16. if [ "$notifications" -gt "$previous" ]; then
  17. dunstify -i data-information -a "Newsboat" "You got $((notifications - previous)) new RSS feeds!"
  18. pw-play /usr/share/sounds/ITGC/notify.flac
  19. echo "$notifications" > ~/.cache/.rss.cache
  20. fi
  21. echo "$notifications" | tee ~/.cache/.rss.cache