tardis (1335B)
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 update() { 12 cd "$annna" && git pull >/dev/null 13 getdimensions 14 } 15 16 getdimensions() { 17 printf '/tv\n' | nc bitreich.org 70 | grep -E '^9.*\.m3u' |\ 18 awk -F' ' '{printf("gopher://%s:%d/%c%s\n", $3, $4, $1, $2)}' \ 19 > "$dimensions" 20 } 21 22 init() { 23 if ! test -r "$hashtags"; then 24 if ! test -d "$(dirname "$annna")"; then 25 mkdir -p "$(dirname "$annna")" 26 fi 27 cd "$(dirname "$annna")" 28 git clone git://bitreich.org/annna 29 fi 30 if ! test -r "$dimensions"; then 31 getdimensions 32 fi 33 } 34 35 init 36 37 if test "$1" = "-u"; then 38 update 39 exit 0 40 fi 41 42 meme="$( (printf '%s\n%s\n' "$updatestr" "$interludestr"; \ 43 cat "$dimensions" "$hashtags") | dmenu -l 10 -p "${0##*/}:")" 44 if test "$meme" = "$updatestr"; then 45 update 46 elif test "$meme" = "$interludestr"; then 47 xdg-open ssh://time-machine@bitreich.org 48 elif test "$meme"; then 49 if printf '%s\n' "$meme" | grep -qE '\.m3u$'; then 50 printf '%s' "${meme}" | xclip -i 51 mpv "$meme" 52 else 53 printf '%s' "${meme% *}" | xclip -i 54 printf '%s' "${meme#* }" | xclip -i -selection clipboard 55 xdg-open "${meme#* }" 56 fi 57 else 58 exit 1 59 fi