commit e49d9d96f85368a63dae45dd360630f60f25c8d3
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Thu, 12 Oct 2023 17:20:14 -0700
Initial commit
Not entirely sure what all I might put here, but for now there's a
Makefile with install and uninstall targets, the script fragment
sfeednew, a README, and example sfeedrc.
Diffstat:
4 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,7 @@
+install:
+ cp sfeednew "$$HOME"/.sfeed
+
+uninstall:
+ rm -f "$$HOME"/.sfeed/sfeednew
+
+.PHONY: install uninstall
diff --git a/README b/README
@@ -0,0 +1,9 @@
+This project provides the ability to access newly merged sfeed items
+by redefining sfeed_update(1)'s merge function.
+
+You could use this for in many ways, but I use it to send an email
+with a summary of the new items to keep from having to open
+sfeed_curses(1). An example of this is shown in sfeedrc. (Another
+possibility would be to use sfeed_mbox(1) on the new items and
+incorperate it into your mail, but I find sfeed_curses(1) is
+preferable to my current mail client for looking at feeds.)
diff --git a/sfeednew b/sfeednew
@@ -0,0 +1,13 @@
+# Copyright 2023 Jacob R. Edwards <jacob@jacobedwards.org>
+
+# To be redefined in sfeedrc
+new() ;
+
+merge() {
+ fifo="$sfeedtmpdir"/fifo_"$filename"
+ mkfifo "$fifo"
+ sort -t ' ' -u -k6,6 -k2,2 -k3,3 "$2" "$3" 2>/dev/null | tee $fifo &
+ {
+ order < "$fifo" | diff "$2" - | awk '/^>/ { print substr($0, 3) }' | new "$1"
+ } >/dev/null
+}
diff --git a/sfeedrc b/sfeedrc
@@ -0,0 +1,36 @@
+# An example sfeedrc using the 'new' hook
+
+. "$HOME"/.sfeed/sfeednew
+
+# sfeedtmpdir isn't defined until just after loading the sfeedrc,
+# so this delays referencing sfeedtmpdir until it's been defined.
+begin() {
+ mail="$sfeedtmpdir"/mail
+ export mail
+}
+
+new() {
+ awk -vname="$1" -F ' ' '{
+ if (!title) {
+ printf "New in %s:\n\n", name
+ title = 1
+ }
+ printf "- %s\n", $2
+ }
+ END {
+ if (title)
+ printf "\n"
+ }' >> "$mail"
+}
+
+end() {
+ test -s "$mail" &&
+ mail -s 'sfeed_update: New feed items' "$(whoami)" < "$mail"
+}
+
+feeds() {
+ begin
+ # feed ...
+ wait
+ end
+}