From 52dd0d6fd34e3ad8bef1cd9e613c71f28c48c33a Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 29 Mar 2018 18:20:49 -0500 Subject: moved filebrowser stuff to examples dir --- examples/filebrowser/action_to_target.sh | 11 ++++++++++ examples/filebrowser/backend-filebrowser.sh | 18 ++++++++++++++++ examples/filebrowser/backend-gopher.sh | 19 +++++++++++++++++ examples/filebrowser/backend-ps.sh | 12 +++++++++++ examples/filebrowser/camera.pos | 2 ++ examples/filebrowser/frontend-hackvr.sh | 6 ++++++ examples/filebrowser/frontend-zenity.sh | 6 ++++++ examples/filebrowser/list_to_cubes.sh | 33 +++++++++++++++++++++++++++++ examples/filebrowser/run | 3 +++ filebrowser/action_to_target.sh | 11 ---------- filebrowser/backend-filebrowser.sh | 18 ---------------- filebrowser/backend-gopher.sh | 19 ----------------- filebrowser/camera.pos | 2 -- filebrowser/frontend-hackvr.sh | 2 -- filebrowser/frontend-zenity.sh | 2 -- filebrowser/list_to_cubes.sh | 33 ----------------------------- filebrowser/run | 3 --- 17 files changed, 110 insertions(+), 90 deletions(-) create mode 100755 examples/filebrowser/action_to_target.sh create mode 100755 examples/filebrowser/backend-filebrowser.sh create mode 100755 examples/filebrowser/backend-gopher.sh create mode 100755 examples/filebrowser/backend-ps.sh create mode 100644 examples/filebrowser/camera.pos create mode 100755 examples/filebrowser/frontend-hackvr.sh create mode 100755 examples/filebrowser/frontend-zenity.sh create mode 100755 examples/filebrowser/list_to_cubes.sh create mode 100755 examples/filebrowser/run delete mode 100755 filebrowser/action_to_target.sh delete mode 100755 filebrowser/backend-filebrowser.sh delete mode 100755 filebrowser/backend-gopher.sh delete mode 100644 filebrowser/camera.pos delete mode 100755 filebrowser/frontend-hackvr.sh delete mode 100755 filebrowser/frontend-zenity.sh delete mode 100755 filebrowser/list_to_cubes.sh delete mode 100755 filebrowser/run diff --git a/examples/filebrowser/action_to_target.sh b/examples/filebrowser/action_to_target.sh new file mode 100755 index 0000000..2abbe58 --- /dev/null +++ b/examples/filebrowser/action_to_target.sh @@ -0,0 +1,11 @@ +#!/bin/sh +#this script gets the action lines that hackvr outputs and turns them into as normal of a string as possible +#for the backend script to use. +#so hex encoded strings need to be unencoded before they leave here. +#the hex encoded strings don't have a newline at the end. we need to add one. see xargs printf "%s0a" +grep --line-buffered ^USER \ + | stdbuf -oL cut '-d ' -f2- \ + | grep --line-buffered ^action \ + | stdbuf -oL cut '-d ' -f2- \ + | xargs -L1 printf "%s0a\n" \ + | stdbuf -oL xxd -r -p diff --git a/examples/filebrowser/backend-filebrowser.sh b/examples/filebrowser/backend-filebrowser.sh new file mode 100755 index 0000000..789b601 --- /dev/null +++ b/examples/filebrowser/backend-filebrowser.sh @@ -0,0 +1,18 @@ +#!/bin/bash +#give a list of files. +#wait for a selection on stdin +#cd or start that file +#repeat. +while true;do +#not sure why this needs to be printed to show up every time. + echo .. + find . -maxdepth 1 #| tr ' ' '\n' #wut? no? + read -r selection + if [ -f "$selection" ];then + xdg-open "$selection" #good enough? + fi + if [ -d "$selection" ];then + cd "$selection" + fi + echo +done diff --git a/examples/filebrowser/backend-gopher.sh b/examples/filebrowser/backend-gopher.sh new file mode 100755 index 0000000..e606667 --- /dev/null +++ b/examples/filebrowser/backend-gopher.sh @@ -0,0 +1,19 @@ +#!/bin/bash +#give a list of files. +#wait for a selection on stdin +#cd or start that file +#repeat. +server=gopher.hacking.allowed.org +port=70 +selection=/ +while true;do +#not sure why this needs to be printed to show up every time. + printf '%s\n' "$selection" | ncat "$server" "$port" | tee /dev/stderr | grep -v ^i | cut -f2 | tr -d '\r' +### need to ask user for input in the form of a pop-up window if the selected target was of type 7 + read -r selection + if [ "_" = "_$selection" ];then + echo "looks like there's nothing here. exiting." >&2 + exit 1 + fi + echo +done diff --git a/examples/filebrowser/backend-ps.sh b/examples/filebrowser/backend-ps.sh new file mode 100755 index 0000000..b06ff99 --- /dev/null +++ b/examples/filebrowser/backend-ps.sh @@ -0,0 +1,12 @@ +#!/bin/bash +#give a list of files. +#wait for a selection on stdin +#cd or start that file +#repeat. +while true;do +#not sure why this needs to be printed to show up every time. + ps | tail -n+2 + read -r selection + echo $selection + echo +done diff --git a/examples/filebrowser/camera.pos b/examples/filebrowser/camera.pos new file mode 100644 index 0000000..718923c --- /dev/null +++ b/examples/filebrowser/camera.pos @@ -0,0 +1,2 @@ +USER move 0 0 0 +USER rotate 0 0 0 diff --git a/examples/filebrowser/frontend-hackvr.sh b/examples/filebrowser/frontend-hackvr.sh new file mode 100755 index 0000000..2b262a9 --- /dev/null +++ b/examples/filebrowser/frontend-hackvr.sh @@ -0,0 +1,6 @@ +#!/bin/bash +if [ "_$1" = "_" ];then + echo "I need an argument for what my backend is." >&2 + exit 1 +fi +cat camera.pos <(stdbuf -oL $1 < p | ./list_to_cubes.sh) | hackvr USER | ./action_to_target.sh > p diff --git a/examples/filebrowser/frontend-zenity.sh b/examples/filebrowser/frontend-zenity.sh new file mode 100755 index 0000000..cb1fa9d --- /dev/null +++ b/examples/filebrowser/frontend-zenity.sh @@ -0,0 +1,6 @@ +#!/bin/bash +if [ "_$1" = "_" ];then + echo "I need a backend script passed as first argument." >&2 + exit 1 +fi +stdbuf -oL $1 < p | stdbuf -oL tr '\n' ' ' | sed -u 's/$/_/' | stdbuf -oL tr '_' '\n' | xargs -L1 zenity --list --column file > p diff --git a/examples/filebrowser/list_to_cubes.sh b/examples/filebrowser/list_to_cubes.sh new file mode 100755 index 0000000..2cdbe92 --- /dev/null +++ b/examples/filebrowser/list_to_cubes.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# blank lines deleteallexcept epoch +# expected input format: +# +# line1 +# line2 +# line3 +# +# line1 +# line2 +j=1 +r=200 +while read -r line;do + if [ "_$line" != '_' ];then +# ../tools/obj2hackvr.pl "$line" ../meshes/cube.obj + #turn line into hex to prevent stupid shit + hexline="$(printf "%s" "$line" | xxd -p | tr -d '\n')" + printf "%s addshape 18 3 8 %d %d 0 %d %d 0 %d %d\n" "$hexline" "$j" "$r" "$[$j+8]" "$r" "$j" "$r" + cd .. + printf "%s\n" "$line" | tee /dev/stderr | ./makelabel.sh "$hexline" 15 $j $r + cd filebrowser + #printf "%s move 0 %d %d 0 0 0 0 0 0\n" "$hexline" "$i" "$r" + printf "%s rotate 0 %d 0\n" "$hexline" "$[i * 3]" + #somehow printf '%s\n' "$line" | ./testfont.sh and make its output belong to same group as $line.. sed? + i=$[i+10] + j=$[j+4] + else + cat camera.pos + printf "USER deleteallexcept USER\n" #deleteallexcept doesn't have gr deletions yet I think. + j=0 + i=0 + fi +done diff --git a/examples/filebrowser/run b/examples/filebrowser/run new file mode 100755 index 0000000..c3bc1d3 --- /dev/null +++ b/examples/filebrowser/run @@ -0,0 +1,3 @@ +#!/bin/bash +cd "$(dirname "$0")" +./frontend-hackvr.sh ./backend-gopher.sh diff --git a/filebrowser/action_to_target.sh b/filebrowser/action_to_target.sh deleted file mode 100755 index 2abbe58..0000000 --- a/filebrowser/action_to_target.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -#this script gets the action lines that hackvr outputs and turns them into as normal of a string as possible -#for the backend script to use. -#so hex encoded strings need to be unencoded before they leave here. -#the hex encoded strings don't have a newline at the end. we need to add one. see xargs printf "%s0a" -grep --line-buffered ^USER \ - | stdbuf -oL cut '-d ' -f2- \ - | grep --line-buffered ^action \ - | stdbuf -oL cut '-d ' -f2- \ - | xargs -L1 printf "%s0a\n" \ - | stdbuf -oL xxd -r -p diff --git a/filebrowser/backend-filebrowser.sh b/filebrowser/backend-filebrowser.sh deleted file mode 100755 index 789b601..0000000 --- a/filebrowser/backend-filebrowser.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -#give a list of files. -#wait for a selection on stdin -#cd or start that file -#repeat. -while true;do -#not sure why this needs to be printed to show up every time. - echo .. - find . -maxdepth 1 #| tr ' ' '\n' #wut? no? - read -r selection - if [ -f "$selection" ];then - xdg-open "$selection" #good enough? - fi - if [ -d "$selection" ];then - cd "$selection" - fi - echo -done diff --git a/filebrowser/backend-gopher.sh b/filebrowser/backend-gopher.sh deleted file mode 100755 index e606667..0000000 --- a/filebrowser/backend-gopher.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -#give a list of files. -#wait for a selection on stdin -#cd or start that file -#repeat. -server=gopher.hacking.allowed.org -port=70 -selection=/ -while true;do -#not sure why this needs to be printed to show up every time. - printf '%s\n' "$selection" | ncat "$server" "$port" | tee /dev/stderr | grep -v ^i | cut -f2 | tr -d '\r' -### need to ask user for input in the form of a pop-up window if the selected target was of type 7 - read -r selection - if [ "_" = "_$selection" ];then - echo "looks like there's nothing here. exiting." >&2 - exit 1 - fi - echo -done diff --git a/filebrowser/camera.pos b/filebrowser/camera.pos deleted file mode 100644 index 718923c..0000000 --- a/filebrowser/camera.pos +++ /dev/null @@ -1,2 +0,0 @@ -USER move 0 0 0 -USER rotate 0 0 0 diff --git a/filebrowser/frontend-hackvr.sh b/filebrowser/frontend-hackvr.sh deleted file mode 100755 index 6a26af0..0000000 --- a/filebrowser/frontend-hackvr.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cat camera.pos <(stdbuf -oL $1 < p | ./list_to_cubes.sh) | hackvr USER | ./action_to_target.sh > p diff --git a/filebrowser/frontend-zenity.sh b/filebrowser/frontend-zenity.sh deleted file mode 100755 index acb7cd7..0000000 --- a/filebrowser/frontend-zenity.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -stdbuf -oL $1 < p | stdbuf -oL tr '\n' ' ' | sed -u 's/$/_/' | stdbuf -oL tr '_' '\n' | xargs -L1 zenity --list --column file > p diff --git a/filebrowser/list_to_cubes.sh b/filebrowser/list_to_cubes.sh deleted file mode 100755 index 2cdbe92..0000000 --- a/filebrowser/list_to_cubes.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# blank lines deleteallexcept epoch -# expected input format: -# -# line1 -# line2 -# line3 -# -# line1 -# line2 -j=1 -r=200 -while read -r line;do - if [ "_$line" != '_' ];then -# ../tools/obj2hackvr.pl "$line" ../meshes/cube.obj - #turn line into hex to prevent stupid shit - hexline="$(printf "%s" "$line" | xxd -p | tr -d '\n')" - printf "%s addshape 18 3 8 %d %d 0 %d %d 0 %d %d\n" "$hexline" "$j" "$r" "$[$j+8]" "$r" "$j" "$r" - cd .. - printf "%s\n" "$line" | tee /dev/stderr | ./makelabel.sh "$hexline" 15 $j $r - cd filebrowser - #printf "%s move 0 %d %d 0 0 0 0 0 0\n" "$hexline" "$i" "$r" - printf "%s rotate 0 %d 0\n" "$hexline" "$[i * 3]" - #somehow printf '%s\n' "$line" | ./testfont.sh and make its output belong to same group as $line.. sed? - i=$[i+10] - j=$[j+4] - else - cat camera.pos - printf "USER deleteallexcept USER\n" #deleteallexcept doesn't have gr deletions yet I think. - j=0 - i=0 - fi -done diff --git a/filebrowser/run b/filebrowser/run deleted file mode 100755 index c3bc1d3..0000000 --- a/filebrowser/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -cd "$(dirname "$0")" -./frontend-hackvr.sh ./backend-gopher.sh -- cgit v1.2.3