tardis - bitreich-tardis - Front-end for navigating bitreich memes and TV dimensions HTML git clone git://bitreich.org/bitreich-tardis git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-tardis DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- tardis (1771B) --- 1 #!/bin/sh 2 # select bitreich tv dimensions and memecache memes. 3 # requirements: lots. 4 5 annna="$HOME/.cache/annna" 6 hashtags="${annna}/modules/hashtags/hashtags.txt" 7 dimensions="${annna}/dimensions.txt" 8 updatestr="update local memecache" 9 interludestr="watch Bitreich TV interlude" 10 11 TARDIS_MENU=${TARDIS_MENU:-"dmenu -l 10 -p ${0##*/}:"} 12 TARDIS_PLUMB=${TARDIS_PLUMB:-xdg-open} 13 TARDIS_VIDEO=${TARDIS_VIDEO:-mpv} 14 15 usage() { 16 printf 'usage: %s [-cuU]\n' "${0##*/}" 1>&2 17 exit 1 18 } 19 20 update() { 21 cd "$annna" && git pull >/dev/null 22 getdimensions 23 cd - >/dev/null 24 } 25 26 getdimensions() { 27 printf '/tv\n' | nc bitreich.org 70 | grep -E '^9.*\.m3u' |\ 28 awk -F' ' '{printf("gopher://%s:%d/%c%s\n", $3, $4, $1, $2)}' \ 29 > "$dimensions" 30 } 31 32 init() { 33 if ! test -r "$hashtags"; then 34 if ! test -d "$(dirname "$annna")"; then 35 mkdir -p "$(dirname "$annna")" 36 fi 37 cd "$(dirname "$annna")" 38 git clone git://bitreich.org/annna 39 fi 40 if ! test -r "$dimensions"; then 41 getdimensions 42 fi 43 } 44 45 init 46 clip="" 47 while getopts uUc arg; do 48 case ${arg} in 49 u) update; exit 0 ;; 50 U) update ;; 51 c) clip=1 ;; 52 *) usage ;; 53 esac 54 done 55 shift $((OPTIND - 1)) 56 if test $# != 0; then 57 usage 58 fi 59 60 meme="$( (printf '%s\n%s\n' "$updatestr" "$interludestr"; \ 61 cat "$dimensions" "$hashtags") | ${TARDIS_MENU})" 62 if test "$meme" = "$updatestr"; then 63 update && exec "$0" 64 elif test "$meme" = "$interludestr"; then 65 ${TARDIS_PLUMB} ssh://time-machine@bitreich.org 66 elif test "$meme"; then 67 if printf '%s\n' "$meme" | grep -qE '\.m3u$'; then 68 if test "$clip"; then 69 printf '%s' "${meme}" | xclip -i 70 fi 71 ${TARDIS_VIDEO} "$meme" 72 else 73 if test "$clip"; then 74 printf '%s' "${meme% *}" | xclip -i 75 printf '%s' "${meme#* }" | xclip -i -selection clipboard 76 fi 77 ${TARDIS_PLUMB} "${meme#* }" 78 fi 79 else 80 exit 1 81 fi