From 06931dfdb443584a2c140bf53a12cff9dc239557 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 2 Jul 2023 13:36:02 +0200 Subject: New feed manager --- old/sfeed-browser | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 old/sfeed-browser (limited to 'old/sfeed-browser') diff --git a/old/sfeed-browser b/old/sfeed-browser new file mode 100755 index 0000000..774c808 --- /dev/null +++ b/old/sfeed-browser @@ -0,0 +1,80 @@ +#!/bin/sh + +# This script is based on sfeed (https://codemadness.org/sfeed.html), but +# it allows you organize your feeds in directories and subdirectories. +# In your $sfd directory (see below) you should have two folders: +# urls: it can contain more subfolders and files. Each file should contain +# only one line with the url to the feed. The name of the file is the +# name of the feed (it can contains spaces and such). +# files: this one can be empty, it will be filled with the feed files +# An older version of this script also marked viewed items and removed +# them before displaying the choice of feeds. Contact me if you are interested +# in using it. + +# Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar) + +# Usage: sfeed-browser [-m menu] + +filepicker="dmenu-filepicker" # Try "nnn -p -" +menu="dmenu -l 35 -i" +urlopener=open-url +sfd="$HOME/box/sfeed" +showlast=10 + +usage() { + echo "sfeed-browser [-m MENU]" +} + +while getopts "m:" opt; do + case "$opt" in + m) + menu="$OPTARG" + ;; + *) + usage + exit 1 + ;; + esac +done + +# Might add more stuff later +fixurl() { + sed 's/old\.reddit\.com/reddit\.com/' +} + +dirtofeedpaths() { + while read -r line; do + find "$line" | while read -r fname; do + [ -f "$fname" ] && echo "$fname" + done + done +} + +pathstosfeedrc() { + printf 'sfeedpath="%s"\n\nfeeds() {\n' "$sfd/files" + while read -r line; do + feedname=$(echo "$line" | sed 's/.*\///') + read -r feedurl <"$line" + printf '\tfeed "%s" "%s"\n' "$feedname" "$feedurl" + done + printf "}\n" +} + +feedmenu() { + while read -r line; do + feedname=$(echo "$line" | sed 's/.*\///') + sfeed_plain "$sfd/files/$feedname" | head -$showlast + done | $menu +} + +openfeeds() { + while read -r line; do + url=$(echo "$line" | sed 's/.*[\t ]//' | fixurl) + [ -n "$url" ] && echo "$url" + done | xargs $urlopener +} + +$filepicker "$@" "$sfd/urls" | dirtofeedpaths > "$sfd/last" +pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" +sfeed_update "$sfd/sfeedrc" +feedmenu < "$sfd/last" | openfeeds -- cgit v1.3