blob: a85b62c08e2351e1fc32d392c2a0794789280c9f (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/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.
# Usage: sfeed-browser [-m menu]
# Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar)
filepicker="dmenu-filepicker" # Try "nnn -p -"
menu="dmenu -l 35 -i"
urlopener=open-url
sfd="$HOME/box/sfeed"
showlast=10
while getopts "m:" opt; do
case "$opt" in
m)
menu="$OPTARG"
;;
esac
done
# Might add more stuff later
fixurl() {
sed 's/old\.reddit\.com/reddit\.com/'
}
dirtofeedpaths() {
while read line; do
find "$line" | while read fname; do
[ -f "$fname" ] && echo "$fname"
done
done
}
pathstosfeedrc() {
printf "sfeedpath=\"$sfd/files\"\n\nfeeds() {\n"
while read line; do
feedname=$(echo "$line" | sed 's/.*\///')
read feedurl <"$line"
printf "\tfeed \"$feedname\" \"$feedurl\"\n"
done
printf "}\n"
}
feedmenu() {
while read line; do
feedname=$(echo "$line" | sed 's/.*\///')
sfeed_plain "$sfd/files/$feedname" | head -$showlast
done | $menu
}
openfeeds() {
while read 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
|