summaryrefslogtreecommitdiff
path: root/scripts/old/sfeed-browser
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/old/sfeed-browser')
-rwxr-xr-xscripts/old/sfeed-browser80
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/old/sfeed-browser b/scripts/old/sfeed-browser
new file mode 100755
index 0000000..774c808
--- /dev/null
+++ b/scripts/old/sfeed-browser
@@ -0,0 +1,80 @@
1#!/bin/sh
2
3# This script is based on sfeed (https://codemadness.org/sfeed.html), but
4# it allows you organize your feeds in directories and subdirectories.
5# In your $sfd directory (see below) you should have two folders:
6# urls: it can contain more subfolders and files. Each file should contain
7# only one line with the url to the feed. The name of the file is the
8# name of the feed (it can contains spaces and such).
9# files: this one can be empty, it will be filled with the feed files
10# An older version of this script also marked viewed items and removed
11# them before displaying the choice of feeds. Contact me if you are interested
12# in using it.
13
14# Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar)
15
16# Usage: sfeed-browser [-m menu]
17
18filepicker="dmenu-filepicker" # Try "nnn -p -"
19menu="dmenu -l 35 -i"
20urlopener=open-url
21sfd="$HOME/box/sfeed"
22showlast=10
23
24usage() {
25 echo "sfeed-browser [-m MENU]"
26}
27
28while getopts "m:" opt; do
29 case "$opt" in
30 m)
31 menu="$OPTARG"
32 ;;
33 *)
34 usage
35 exit 1
36 ;;
37 esac
38done
39
40# Might add more stuff later
41fixurl() {
42 sed 's/old\.reddit\.com/reddit\.com/'
43}
44
45dirtofeedpaths() {
46 while read -r line; do
47 find "$line" | while read -r fname; do
48 [ -f "$fname" ] && echo "$fname"
49 done
50 done
51}
52
53pathstosfeedrc() {
54 printf 'sfeedpath="%s"\n\nfeeds() {\n' "$sfd/files"
55 while read -r line; do
56 feedname=$(echo "$line" | sed 's/.*\///')
57 read -r feedurl <"$line"
58 printf '\tfeed "%s" "%s"\n' "$feedname" "$feedurl"
59 done
60 printf "}\n"
61}
62
63feedmenu() {
64 while read -r line; do
65 feedname=$(echo "$line" | sed 's/.*\///')
66 sfeed_plain "$sfd/files/$feedname" | head -$showlast
67 done | $menu
68}
69
70openfeeds() {
71 while read -r line; do
72 url=$(echo "$line" | sed 's/.*[\t ]//' | fixurl)
73 [ -n "$url" ] && echo "$url"
74 done | xargs $urlopener
75}
76
77$filepicker "$@" "$sfd/urls" | dirtofeedpaths > "$sfd/last"
78pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc"
79sfeed_update "$sfd/sfeedrc"
80feedmenu < "$sfd/last" | openfeeds

Generated with cgit - Back to sebastiano.tronto.net