memeselect (1077B)
1 #!/bin/sh 2 # select bitreich tv dimensions and memecache memes. 3 4 annna="$HOME/.cache/annna" 5 hashtags="${annna}/modules/hashtags/hashtags.txt" 6 updatestr="update local memecache" 7 8 # fetch bitreich tv dimensions 9 if command -v nc >/dev/null 2>&1; then 10 dimensions="$(printf '/tv\n' | nc bitreich.org 70 | grep -E '^9.*\.m3u' |\ 11 awk -F' ' '{printf("gopher://%s:%d/%c%s\n", $3, $4, $1, $2)}')" 12 fi 13 14 # fetch annna's memecache listing 15 if ! test -d "$(dirname "$annna")"; then 16 mkdir -p "$(dirname "$annna")" 17 fi 18 if ! test -d "$annna"; then 19 cd "$(dirname "$annna")" 20 git clone git://bitreich.org/annna 21 fi 22 23 # present meme choices in dmenu 24 meme="$((printf '%s\n' "$updatestr"; printf '%s\n' "$dimensions"; \ 25 cat "$hashtags") | dmenu -l 10)" 26 27 if test "$meme" = "$updatestr"; then 28 cd "$annna" && git pull >/dev/null 29 elif test "$meme"; then 30 if printf '%s\n' "$meme" | grep -qE '\.m3u$'; then 31 printf '%s' "${meme}" | xclip -i 32 mpv "$meme" 33 else 34 printf '%s' "${meme% *}" | xclip -i 35 printf '%s' "${meme#* }" | xclip -i -selection clipboard 36 xdg-open "${meme#* }" 37 fi 38 else 39 exit 1 40 fi