diff options
Diffstat (limited to 'old')
| -rwxr-xr-x | old/sfeed-browser | 80 |
1 files changed, 80 insertions, 0 deletions
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 @@ | |||
| 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 | |||
| 18 | filepicker="dmenu-filepicker" # Try "nnn -p -" | ||
| 19 | menu="dmenu -l 35 -i" | ||
| 20 | urlopener=open-url | ||
| 21 | sfd="$HOME/box/sfeed" | ||
| 22 | showlast=10 | ||
| 23 | |||
| 24 | usage() { | ||
| 25 | echo "sfeed-browser [-m MENU]" | ||
| 26 | } | ||
| 27 | |||
| 28 | while getopts "m:" opt; do | ||
| 29 | case "$opt" in | ||
| 30 | m) | ||
| 31 | menu="$OPTARG" | ||
| 32 | ;; | ||
| 33 | *) | ||
| 34 | usage | ||
| 35 | exit 1 | ||
| 36 | ;; | ||
| 37 | esac | ||
| 38 | done | ||
| 39 | |||
| 40 | # Might add more stuff later | ||
| 41 | fixurl() { | ||
| 42 | sed 's/old\.reddit\.com/reddit\.com/' | ||
| 43 | } | ||
| 44 | |||
| 45 | dirtofeedpaths() { | ||
| 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 | |||
| 53 | pathstosfeedrc() { | ||
| 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 | |||
| 63 | feedmenu() { | ||
| 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 | |||
| 70 | openfeeds() { | ||
| 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" | ||
| 78 | pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" | ||
| 79 | sfeed_update "$sfd/sfeedrc" | ||
| 80 | feedmenu < "$sfd/last" | openfeeds | ||
