dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

newsrefreshd (746B)


      1 #!/bin/sh
      2 # This script refreshes newsboat. Runs via a LaunchAgent or cronjob.
      3 set -e
      4 
      5 notidie() {
      6   notify "$1" "$2" news
      7   exit 1
      8 }
      9 
     10 os=$(uname -s | tr '[:upper:]' '[:lower:]')
     11 case "$os" in
     12   darwin*)
     13     while pgrep RotMG; do sleep 60; done
     14     while pgrep pinentry; do sleep 60; done
     15     /usr/local/bin/alacritty -e /usr/local/bin/rbw unlock
     16     /usr/local/bin/rbw unlocked || notidie "Newsboat: error reloading" "Vault is locked"
     17     ;;
     18 esac
     19 
     20 unreadbefore="$(newsboat -x print-unread | cut -d' ' -f1)"
     21 newsboat -x reload 2>&1 || notidie "Newsboat: error reloading" "Unable to reload"
     22 unreadafter="$(newsboat -x print-unread | cut -d' ' -f1)"
     23 notify 'Newsboat reloaded' "$((unreadafter-unreadbefore)) new articles ($unreadafter total)" news