[download]

local/bin/news-menu

   1 #!/bin/bash
   2 
   3 source icon
   4 cd ~/.newsboat || exit
   5 
   6 db(){ # {{{
   7     sqlite3 -separator $'\t' cache.db "$@"
   8 } # }}}
   9 print(){ # {{{
  10     while read unread feedurl url title; do
  11         [[ $unread == 1 ]] && i=$(icon news-"$url") || i='  '
  12         printf '%s %s\t%s\t%s\n' "$i" "${map[$feedurl]}" "$title" "$url"
  13     done
  14 } # }}}
  15 
  16 declare -A map
  17 while read url name; do map[$url]=${name:2:-1}; done < <(grep '^http' urls)
  18 
  19 s=$(db 'select unread, feedurl, url, title from rss_item order by unread desc, pubDate desc' |
  20 print | column -ts $'\t' | menu -i news -l 15 | awk '{ print "\"" $NF "\"" }' | paste -sd ,)
  21 
  22 [[ $s ]] || exit
  23 db "update rss_item set unread = 0 where url in ($s)"
  24 chromium $(db "select url from rss_item where url in ($s) order by id desc") &