commit d9739f9c27c45ac9b840bdee983bed9b34a88f3d parent a25d41ff3157535738b3a68dd239b62de9645d49 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Sun, 14 Feb 2021 00:47:46 +0100 memeselect: add bitreich-tv stations Diffstat:
M | .local/bin/memeselect | | | 29 | +++++++++++++++++++++++------ |
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/.local/bin/memeselect b/.local/bin/memeselect @@ -1,22 +1,39 @@ #!/bin/sh +# select bitreich tv dimensions and memecache memes. + annna="$HOME/.cache/annna" hashtags="${annna}/modules/hashtags/hashtags.txt" -updatestr="update list" +updatestr="update local memecache" + +# fetch bitreich tv dimensions +if command -v sacc >/dev/null 2>&1; then + dimensions="$(sacc bitreich.org/0/tv | grep .m3u | \ + awk -F' ' '{printf("gopher://%s:%d/%c%s\n", $3, $4, $1, $2)}')" +fi +# fetch annna's memecache listing if ! test -d "$(dirname "$annna")"; then mkdir -p "$(dirname "$annna")" fi - if ! test -d "$annna"; then cd "$(dirname "$annna")" git clone git://bitreich.org/annna fi -m="$((printf '%s\n' "$updatestr"; cat "$hashtags") | dmenu -l 10)" +# present meme choices in dmenu +meme="$((printf '%s\n' "$updatestr"; printf '%s\n' "$dimensions"; \ + cat "$hashtags") | dmenu -l 10)" -if [ "$m" = "$updatestr" ]; then +if test "$meme" = "$updatestr"; then cd "$annna" && git pull >/dev/null +elif test "$meme"; then + if printf '%s\n' "$meme" | grep -qE '\.m3u$'; then + mpv "$meme" + else + printf '%s' "${meme% *}" | xclip -i + printf '%s' "${meme#* }" | xclip -i -selection clipboard + xdg-open "${meme#* }" + fi else - printf '%s' "${m% *}" | xclip -i - plumb "${m#* }" + exit 1 fi