diff --git a/Makefile b/Makefile index fe7308e..bbe7512 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ man: sh: mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f sh/paste $(DESTDIR)$(PREFIX)/bin + cp -f sh/trss $(DESTDIR)$(PREFIX)/bin cp -f sh/disp $(DESTDIR)$(PREFIX)/bin cp -f sh/wallpaper $(DESTDIR)$(PREFIX)/bin cp -f sh/yt $(DESTDIR)$(PREFIX)/bin diff --git a/sh/trss b/sh/trss new file mode 100755 index 0000000..c7e0180 --- /dev/null +++ b/sh/trss @@ -0,0 +1,39 @@ +#!/bin/sh + +# get configuration & data directories +DATA="$HOME/.cache/trss" +CONFIG="$HOME/.config/trss" + +# make sure these directories are in place +mkdir -p "$DATA" +mkdir -p "$CONFIG" + +import_information () { + FEEDS="" + for i in "$CONFIG"/*; do + . "$i" + [ -z "$FEEDS" ] && FEEDS="$NAME" || FEEDS="$FEEDS $NAME" + done +} + +synchronize () { + for i in $FEEDS; do + url="$(get_feed_attr "$i" feed)" + printf "> synchronizing feed %s via url %s\n" "$i" "$url" + curl "$url" -so "$DATA/${i}.xml" + + # generate sfeed formatted file + printf "> creating sfeed compound feed file for feed %s\n" "$i" + cat "$DATA/${i}.xml" | sfeed | cat - "$DATA/${i}.sfeed" | uniq >> "$DATA/${i}.tmp.sfeed" + mv "$DATA/${i}.tmp.sfeed" "${DATA}/${i}.sfeed" + done +} + +get_feed_attr () { + eval "printf '%s' \${$1_$2}" +} + +import_information +synchronize +printf "%s\n" "$FEEDS" +get_feed_attr seirdy humanname