updated for remotestorage

This commit is contained in:
Leon van Kammen 2025-05-22 17:18:11 +02:00
parent bbe1cf10ee
commit ff80d2fb9e
14 changed files with 65 additions and 28 deletions

Binary file not shown.

View file

@ -35,11 +35,12 @@ help_tips(){
echo '----' echo '----'
echo 'text editors ' "type '<cm|vi|mg|nano> <textfile>'" echo 'text editors ' "type '<cm|vi|mg|nano> <textfile>'"
echo 'programming languages ' "type 'ls ~/bin/helloworld*'" echo 'programming languages ' "type 'ls ~/bin/helloworld*'"
echo 'run 64bit linux app ' "type 'blink <x86_64 binary>'" echo 'upload file to xrsh ' "type 'upload <file>'"
echo 'download file locally ' "type 'download <file>'"
echo 'paste text ' "ctrl/cmd+shift+v'" echo 'paste text ' "ctrl/cmd+shift+v'"
echo 'paste text to file ' "ctrl/cmd+v'" echo 'paste text to file ' "ctrl/cmd+v'"
echo 'import file to scene ' "drag-drop file or ctrl/cmd+v or type 'upload'" echo 'import file to scene ' "drag-drop file or ctrl/cmd+v or type 'upload'"
echo 'import remote URL ' "type 'require <https://xrfragment.org/index.glb>'" echo 'import remote URL ' "type 'require https://xrfragment.org/index.glb'"
echo 'reset scene & shell ' "type 'reset'" echo 'reset scene & shell ' "type 'reset'"
echo 'js run ' "type 'js 'alert(\"hello\")'" echo 'js run ' "type 'js 'alert(\"hello\")'"
echo 'js console.log: ' "type 'console document.baseURI" echo 'js console.log: ' "type 'console document.baseURI"
@ -47,7 +48,6 @@ help_tips(){
echo 'js inspect: ' "type 'js \"return document.baseURI\"'" echo 'js inspect: ' "type 'js \"return document.baseURI\"'"
echo 'js capture console: ' "type 'tail -f /dev/browser/console'" echo 'js capture console: ' "type 'tail -f /dev/browser/console'"
echo 'js<->filesystem hooks:' "type 'see [executable] files in ~/hook.d'" echo 'js<->filesystem hooks:' "type 'see [executable] files in ~/hook.d'"
echo 'include file into page' "type 'require <url.js|css>'"
echo 'say something ' "type 'say hello'" echo 'say something ' "type 'say hello'"
echo '' echo ''
echo 'type "help" or "man xrsh" to read the full manual' echo 'type "help" or "man xrsh" to read the full manual'

View file

@ -32,19 +32,7 @@ test -f /root/.boot || {
touch /root/.boot # make sure we run below once touch /root/.boot # make sure we run below once
# add menu items https://xrsh.isvery.ninja/#Launcher%20menu # add menu items https://xrsh.isvery.ninja/#Launcher%20menu
find /root/.config/launcher -type f | while read item; do /root/bin/launcher init
js '
let term = document.querySelector("[isoterminal]").components.isoterminal.term
launcher.register({
name: "'$(basename $item)'",
cb: () => term.exec("'$item'")
})
return "'$item'"
'
done > /tmp/log
# get latest xrfragments to support interactive models
require https://xrfragment.org/dist/xrfragment.aframe.js
# start index.js if /dev/browser/js filesize is not great than 0 # start index.js if /dev/browser/js filesize is not great than 0
if [ ! -s /dev/browser/js ]; then if [ ! -s /dev/browser/js ]; then

View file

@ -0,0 +1,19 @@
#!/bin/sh
init(){
# add menu items https://xrsh.isvery.ninja/#Launcher%20menu
{ find /root/.config/launcher -type f; find /root/.config/launcher -type l; } | while read item; do
js '
let term = document.querySelector("[isoterminal]").components.isoterminal.term
launcher.register({
name: "'$(basename $item)'",
cb: () => term.emit("exec",["'$item'"])
})
return "'$item'"
'
done > /tmp/log
}
"$@"

View file

@ -4,8 +4,8 @@ source /etc/profile.sh
state(){ state(){
javascript=' javascript='
const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.term const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.term
isoterminal.save() isoterminal.save({'$1':true})
return "[OK] xrsh state saved\n" return "\n"
' '
echo "[i] triggering ~/hook.d/save/* scripts" echo "[i] triggering ~/hook.d/save/* scripts"
@ -16,6 +16,9 @@ state(){
exit exit
} }
test -z "$1" && state test -n "$1" && state "$1"
echo "Usage: save" test -z "$1" && {
echo "it saves VM state to localStorage" echo "Usage: save [localstorage|remotestorage]"
echo ""
echo "save VM (filesystem) to local (=default) or remotestorage"
}

View file

@ -1,9 +1,10 @@
#!/bin/sh #!/bin/sh
exec inotifyd echo /root /root/.config/launcher | awk '
infinite inotifyd echo /root | awk '
# listen for writes to rootdir and send them to DOM # listen for writes to rootdir and send them to DOM
/^[wne] \/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") } /^[wne] \/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") }
/^[wne] \/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") } /^[wne] \/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") }
/^[wne] \/root\/.config\/launcher/ { system("/root/bin/launcher init") }
/.*/ { system("logger "$0) }
' '

View file

@ -0,0 +1,13 @@
#!/bin/html
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
<a-plane position="0 0.05 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
<!--
<a-box position="0 1.4 -0.5" scale="0.2 0.2 0.2" color="#FF00AA" grabbable></a-box>
-->
<!-- for [lowerlevel] THREE.js code see ~/index.js -->

View file

@ -6,6 +6,11 @@ if [[ "$1" =~ "pos=|t=" ]]; then
echo "[.] detected Media/XR Fragment in URI" echo "[.] detected Media/XR Fragment in URI"
fi fi
if [[ "$1" =~ "access_token=" ]]; then
# remotestorage redirect oAuth
exit 0
fi
if [[ "$1" =~ "zip$" ]]; then if [[ "$1" =~ "zip$" ]]; then
echo "[.] detected XRSH zip package in URL" echo "[.] detected XRSH zip package in URL"
echo "[.] fetching $1" echo "[.] fetching $1"

View file

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
# launcher init
/root/bin/launcher init &
# intialize global funcs # intialize global funcs
/root/index.js &> /dev/null /root/index.js &> /dev/null

View file

@ -51,6 +51,13 @@ Currently the following languages are supported:
* nano (busybox nano) * nano (busybox nano)
* mg (microemacs) * mg (microemacs)
# Autoboot
To skip the bootmenu you can provide a bootoption via the URL:
* autoboot the ISO: http://xrsh.isvery.ninja/src/index.html#1
* autoboot and run `date` cmd: http://localhost:8080/src/index.html#1&date
# Multiple terminals [GNU screen] # Multiple terminals [GNU screen]
## From the cmdline ## From the cmdline

View file

@ -13,5 +13,6 @@ else
fi fi
$me/codemirror.js "$file" $2 $3 $4 $me/codemirror.js "$file" $2 $3 $4
echo "NOTE: codemirror can only edit files in /mnt (for now)"
echo "press ctrl-Q to exit editor" echo "press ctrl-Q to exit editor"

View file

@ -1,4 +1,3 @@
#!/bin/sh #!/bin/sh
cd $(dirname $(readlink -f $0))
echo "loading AFRAME glTF scene" echo "loading AFRAME glTF scene"
cp index.html /root/index.html cp index.html /root/index.html

View file

@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
cd $(dirname $(readlink -f $0))
echo "loading THREE.js scene" echo "loading THREE.js scene"
echo "" > /root/index.html # empty scene echo "" > /root/index.html # empty scene
cp index.js /root/index.js cp index.js /root/index.js

View file

@ -1,4 +1,3 @@
#!/bin/sh #!/bin/sh
cd $(dirname $(readlink -f $0))
echo "loading AFRAME demo scene" echo "loading AFRAME demo scene"
cp index.html /root/index.html cp index.html /root/index.html