diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-06-10 18:58:52 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-06-10 18:58:52 +0200 |
| commit | b98e05ba63f2e108df634b4d9f9e5530769c6b80 (patch) | |
| tree | a1d3a7f20e826d264f2a6b2141b7b1bfa7debb6f /sfeed-browser | |
| parent | ed61c5f085cebb86d3d3a34ce01ec22069c1fc70 (diff) | |
| download | scripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.tar.gz scripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.zip | |
Added scripts and readme
Diffstat (limited to '')
| -rwxr-xr-x | sfeed-browser | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sfeed-browser b/sfeed-browser new file mode 100755 index 0000000..be56d74 --- /dev/null +++ b/sfeed-browser | |||
| @@ -0,0 +1,62 @@ | |||
| 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 | filepicker="dmenu-filepicker" # Try "nnn -p -" | ||
| 17 | menu=${MENU:-dmenu} | ||
| 18 | menuopts="-l 35 -i" | ||
| 19 | urlopener=open-url | ||
| 20 | sfd="$XDG_CONFIG_HOME/sfeed" | ||
| 21 | showlast=10 | ||
| 22 | |||
| 23 | # Might add more stuff later | ||
| 24 | fixurl() { | ||
| 25 | sed 's/old\.reddit\.com/reddit\.com/' | ||
| 26 | } | ||
| 27 | |||
| 28 | dirtofeedpaths() { | ||
| 29 | while read line; do | ||
| 30 | find "$line" | while read fname; do | ||
| 31 | [ -f "$fname" ] && echo "$fname" | ||
| 32 | done | ||
| 33 | done | ||
| 34 | } | ||
| 35 | |||
| 36 | pathstosfeedrc() { | ||
| 37 | printf "sfeedpath=\"$sfd/files\"\n\nfeeds() {\n" | ||
| 38 | while read line; do | ||
| 39 | feedname=$(echo "$line" | sed 's/.*\///') | ||
| 40 | read feedurl <"$line" | ||
| 41 | printf "\tfeed \"$feedname\" \"$feedurl\"\n" | ||
| 42 | done | ||
| 43 | printf "}\n" | ||
| 44 | } | ||
| 45 | |||
| 46 | feedmenu() { | ||
| 47 | while read line; do | ||
| 48 | feedname=$(echo "$line" | sed 's/.*\///') | ||
| 49 | sfeed_plain "$sfd/files/$feedname" | head -$showlast | ||
| 50 | done | $menu $menuopts | ||
| 51 | } | ||
| 52 | |||
| 53 | openfeeds() { | ||
| 54 | while read line; do | ||
| 55 | url=$(echo "$line" | sed 's/.*[\t ]//' | fixurl) | ||
| 56 | [ -n "$url" ] && echo $url | ||
| 57 | done | xargs $urlopener | ||
| 58 | } | ||
| 59 | |||
| 60 | $filepicker "$sfd/urls" | dirtofeedpaths > "$sfd/last" | ||
| 61 | pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" | ||
| 62 | sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds | ||
