summaryrefslogtreecommitdiff
path: root/.local/bin/dwmbar/dwmb-rss
blob: 07b993f7e39772989128dcaa62b8526d7d85f43b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
cd "$HOME/.sfeed" || exit 1

LC_ALL=C awk -F '\t' '
# URL file: amount of fields is 1.
NF == 1 {
  u[$1] = 1; # lookup table of URLs
  next;
}
# feed file: check by URL or id.
{
  total++;
  if (u[$3] || u[$6])
    read++
}
END {
  feedcount=(total - read - 1)
  if (feedcount == 0)
     print ""
  else
    print "  " (feedcount)
  # print "Unread: " (total - read)
  # print "Read:   " read
  # print "Total:  " total
}
' urls feeds/*

case $BUTTON in
	1) killall sfeed_curses || st -t rss -e sfeed_curses $HOME/.sfeed/feeds/* ;;
  3) notify-send -a " News" "Updating..." && \
     sfeed_update && notify-send -a " News" "Done!" \
     || notify-send -a " News" "Something happened..."
     sleep 0.2 && kill -37 $(pidof dwmblocks) ;;
	6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac