~mil/f_scripts

ref: d7dfa08773dbdf54e3e5e47ff615364a2acc2cc0 f_scripts/scripts/f_rss -rwxr-xr-x 2.1 KiB
d7dfa087Miles Alan genscripts/gen_alpinepackage.sh: Update APKBUILD generator based on feedback 8 months ago
                                                                                
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
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env osh
shopt -s strict:all
DEP="sfeed sfeed_curses"
DEC="Fetches data from RSS via sfeed and allows you to view via sfeed_curses"
DOC="
  Allows you to fetch RSS feeds via sfeed and then view via sfeed_curses with
  keybindings pre-setup in fbp.

  Use the env variable \$F_SFEEDRC_DATA to customize the sfeedrc data contents.
"
VAR='
  F_SFEEDRC_DATA="
    feeds() {
      feed "Tech/Pine64"   "https://www.pine64.org/rss"
      feed "Tech/Slashdot" "http://feeds.feedburner.com/SlashdotSitenews"
      feed "Tech/HN" "https://news.ycombinator.com/rss"
      feed "Tech/Lobsters" "https://lobste.rs/rss"
      feed "Tech/Suckless" "http://git.suckless.org/sites/atom.xml"
    }
  "
'

w3msetfbp() {
  { 
    echo -e "\b\f\e"; 
    echo "g + - j k w b B \\t \\n u v Q" | tr " " "\n" 
  }  > /tmp/fbp.fifo
}

w3mpath() {
  # By default C-c just stops loading; fbp sends C-c
  local CFG SCRIPT
  CFG="$(mktemp)"
  echo "keymap  C-c EXIT" > "$CFG"

  SCRIPT="$(mktemp)"
  echo '#!/usr/bin/env sh
f_rss w3msetfbp
w3m -o keymap_file="'$CFG'" "$@"
[ -p /tmp/fbp.fifo ] && { echo -e "\b\f\e"; echo "j k \\t \\n o Q" | tr " " "\n"; } > /tmp/fbp.fifo
' > $SCRIPT
  chmod +x $SCRIPT
  echo "$SCRIPT"
}

sfeedruncurses() {
  { echo -e "\b\f\e"; echo "j k \\t \\n o q" | tr " " "\n"; } > /tmp/fbp.fifo

  local W3MCONFIG
  W3MCONFIG="$(w3mpath)"
  export TERM=xterm
  export SFEED_PIPER="$W3MCONFIG"
  export SFEED_PIPER_INTERACTIVE=1
  export SFEED_PLUMBER="$W3MCONFIG"
  export SFEED_PLUMBER_INTERACTIVE=1
  export SFEED_AUTOCMD=2
  sfeed_curses ~/.sfeed/feeds/*
  echo -e "\r" > /tmp/fbp.fifo
}

sfeedrunupdate() {
  SFEED_CONF="$(mktemp)"
  echo "$F_SFEEDRC_DATA" > $SFEED_CONF
  sfeed_update "$SFEED_CONF"
}

main() {
  local ACTION OPTS

  env | grep -q "^$(basename "$0" | tr '[a-z]' '[A-Z]')=" || eval "$VAR"

  while true; do
    OPTS="update browse"
    [ -p /tmp/fbp.fifo ] && { echo -e "\b\f\r"; echo "$OPTS" | tr " " "\n"; } > /tmp/fbp.fifo
    read -p "Action ($OPTS): " ACTION
    [ "$ACTION" = update ] && sfeedrunupdate
    [ "$ACTION" = browse ] && sfeedruncurses
  done
}

if [ -n "$1" ]; then "$@"; else main; fi