diff --git a/buildroot-v86/board/v86/rootfs_overlay/etc/motd b/buildroot-v86/board/v86/rootfs_overlay/etc/motd index a4e8528..5ecbec9 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/etc/motd +++ b/buildroot-v86/board/v86/rootfs_overlay/etc/motd @@ -3,6 +3,7 @@ Welcome to XRSH Please hook up your (bluetooth) keyboard to use xrsh. Use Ctrl+a+0/1/2/3/.. to switch terminals. Use Ctrl+a+c to create a new terminal. -Use 'save' to save session (survives tab-close) +Type 'save' to save session (survives tab-close) +Type 'help_tips' for tips Happy hacking! \o/ diff --git a/buildroot-v86/board/v86/rootfs_overlay/etc/profile b/buildroot-v86/board/v86/rootfs_overlay/etc/profile index eab8d0a..447045a 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/etc/profile +++ b/buildroot-v86/board/v86/rootfs_overlay/etc/profile @@ -1,5 +1,5 @@ export HOME=/root -export PATH=$PATH:/etc:~/bin +export PATH=~/bin:$PATH:/etc # source URL data from v86 (file created by v86 during boot) test -f /mnt/profile.browser && source /mnt/profile.browser @@ -33,13 +33,16 @@ help_tips(){ echo 'text editors ' "type ' '" echo 'programming languages ' "type 'ls ~/bin/helloworld*'" echo 'run 64bit linux app ' "type 'blink '" + echo 'paste text ' "ctrl/cmd+shift+v'" + echo 'paste text to file ' "ctrl/cmd+v'" + echo 'import file to scene ' "drag-drop or ctrl/cmd+v'" + echo 'reset scene & shell ' "type 'reset'" echo 'js run ' "type 'js 'alert(\"hello\")'" echo 'js console.log: ' "type 'console document.baseURI" echo 'js function as cmd: ' "type 'alias $1=\"jsh $1\"' to run '$1 yo' as $1('yo')" echo 'js inspect: ' "type 'js \"return document.baseURI\"'" - echo 'js console mute: ' "type 'echo 0 > /dev/browser/tty' to disable" echo 'js capture console: ' "type 'tail -f /dev/browser/console'" - echo 'jsh<->sh hooks: ' "type 'chmod +x ~/hook.d/*/* && alert helloworld'" + echo 'js<->filesystem hooks:' "type 'see [executable] files in ~/hook.d'" echo 'include file into page' "type 'require '" echo '' echo 'type "help" or "man xrsh" to read the full manual' diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/a-gltf-model b/buildroot-v86/board/v86/rootfs_overlay/root/bin/a-gltf-model index c4909c0..28cadf6 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/bin/a-gltf-model +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/a-gltf-model @@ -1,6 +1,7 @@ #!/bin/sh test -n "$1" || { echo "usage: a-gltf-model "; exit; } -file="${1#/}" # strip leading slash if present +file="$(readlink -f "$1")" +file="${file#/}" # strip leading slash if present echo "" >> /root/index.html diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/reset b/buildroot-v86/board/v86/rootfs_overlay/root/bin/reset new file mode 100755 index 0000000..df5a814 --- /dev/null +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/reset @@ -0,0 +1,6 @@ +#!/bin/sh +/usr/bin/reset +set -x +echo '' > ~/index.html # empty scene +set +x +echo "[i] terminal and 3D scene are re-initialized" diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/save b/buildroot-v86/board/v86/rootfs_overlay/root/bin/save index 45888ac..f9d763f 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/bin/save +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/save @@ -7,7 +7,8 @@ javascript=' return "[OK] xrsh state saved\n" ' -echo "[OK] triggering ~/hook.d/save/* scripts" +echo "[i] triggering ~/hook.d/save/* scripts" hook save -echo "[..] please wait.." +echo "[i] warning: do not resize the browserwindow" +echo "[i] please wait.." js "$javascript" diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/mimetype/application/zip/extract_and_run.sh b/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/mimetype/application/zip/extract_and_run.sh new file mode 100755 index 0000000..aa17947 --- /dev/null +++ b/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/mimetype/application/zip/extract_and_run.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e # halt on error +file="$1" +dir="$(basename "$file")" + +logger "$0: extracting $file" + +mkdir -p "/root/$dir" +cd "/root/$dir" +unzip "$file" + +test -x app && { + logger "$0: detected $(pwd)/app executable" + logger "$0: running $(pwd)/app" + ./app +} diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/manual.md b/buildroot-v86/board/v86/rootfs_overlay/root/manual.md index 05806c9..2ce8b6a 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/root/manual.md +++ b/buildroot-v86/board/v86/rootfs_overlay/root/manual.md @@ -1,6 +1,7 @@ XRSH Manual =========== +``` . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ____ _____________ ________. ._. ._. . . . . . . . . . . _\ \/ /\______ \/ _____// | \. . . . . . . . @@ -8,7 +9,7 @@ XRSH Manual _ _ / \ | | \/ \ Y / _ _ _ _ _ _ _ . . /___/\ \ |____|_ /_______ /\___|_ /. . . . . . . . . . . . . .\_/. . . . \/ . . . .\/ . . _ \/ . . . . . . . . - ▬▬▬▬ https://xrsh.isvery.ninja ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ + ================ https://xrsh.isvery.ninja ================ Open, local-first, polyglot, unix hackable & selfcontained XR apps. Using worlds first WebXR linux distro. @@ -17,6 +18,7 @@ XRSH Manual all FOSS devs | copy.sh (v86) aframe.io (AFRAME) Leon van Kammen | @lvk@mastodon.online Fabien Benetou | @utopiah@mastodon.pirateparty.be +``` # Getting started @@ -49,44 +51,66 @@ Currently the following languages are supported: * nano (busybox nano) * mg (microemacs) -# Boot sequence +# Multiple terminals [GNU screen] -The following files are loaded during boot (via `/etc/profile`) +## From the cmdline -| file | info | -|-----------------------|---------------------------------------------------| -| /etc/profile.xrsh | sets up xrsh environment | -| /etc/profile.sh | global shellscript functions | -| /etc/profile.js | global javascript functions | -| /mnt/profile.browser | environment vars set by browser (`echo $HOSTNAME`)| -| /root/.profile | user shellscript functions/settings | -| /root/.profile.js | user javascript functions | -| /root/.screenrc | GNU screen initialisations | -| https://.../#ls | URI fragment is executed as command in own screen | - -> TIP: to keep things portable with future versions of XRSH: modify files in `/root/*` - -# Calling terminal from javascript - -```javascript -const term = document.querySelector('[isoterminal]').components.isoterminal.term -term.exec("ls -la") - -// interact directly with files -await term.worker.create_file("hello.txt", term.convert.toUint8Array("hello") ) -await term.worker.update_file("hello.txt", term.convert.toUint8Array("hi") ) -await term.worker.append_file("hello.txt", term.convert.toUint8Array("world") ) -const f = await term.worker.read_file("hello.txt") +``` +xrsh # screen –DR # list of detached screen +xrsh # screen –r PID # attach detached screen ses­sion +xrsh # screen –dmS Myses # start a detached screen ses­sion +xrsh # screen –r MySes #attach screen ses­sion with name MySession ``` -# Calling javascript from terminal +## Basics -Various options: +``` +ctrl a c -> create new window +ctrl a A -> set win­dow name +ctrl a w -> show all win­dow +ctrl a 1|2|3|… -> switch to win­dow n +ctrl a " -> choose win­dow +ctrl a ctrl a -> switch between win­dow +ctrl a d -> detach win­dow +ctrl a ? -> help +ctrl a [ -> start copy, move cur­sor to the copy loca­tion, press ENTER, select the chars, press ENTER to copy the selected char­ac­ters to the buffer +ctrl a ] -> paste from buffer +``` -1. Just add the `#!/bin/js` shebang to the top of a javascript file (+ chmod +x) -2. Run `js "alert('hello')"` in the shell -3. Run `jsh alert hello` in the shell -4. Run `jsh` to start an interactive shell +## Advanced + +``` +ctrl a S -> cre­ate split screen +ctrl a TAB -> switch between split screens +ctrl a Q -> Kill all regions but the cur­rent one. +ctrl a X -> remove active win­dow from split screen +ctrl a O -> logout active win­dow (dis­able out­put) +ctrl a I -> login active win­dow (enable output) +``` + +# Importing files + +Files can be imported (always to /mnt/clipboard) in various ways: + +* copy-pasted text (from clipboard via ctrl/cmd+v ) +* drag-dropped file ends up in /mnt/clipboard [based on ~/hook.d/mimetype/* things happen or not] +* type 'upload' to trigger a file-upload dialog [ends up in /mnt/clip + +XRSH ships with hooks for importing .glb 3D files, text-files & zip-packages, all described below. + +# XRSH Packages + +A XRSH package is just a zip with an entrypoint, which gets extracted to /root/{zipname} that's it! + +It can be loaded in various ways into [your own instance of] https://xrsh.isvery.ninja: + +* copy the zip in a filemanager to your clipboard, and paste it into your XRSH-tab +* drag-drop the zip from a filemanager to your XRSH-tab +* download the zip, and type 'upload' in XRSH to import it + +Currently, 'app' links to 'bin/app.sh', but there are also other scriptinglanguages it could link to as well (see bin-folder). + +> see example package at https://xrsh.isvery.ninja/package.zip # Hooks @@ -132,42 +156,6 @@ But you can do it manually too: These are various ways to enable hybrid eventing between browser and terminal (languages). -# Multiple terminals [GNU screen] - -## From the cmdline - -``` -xrsh # screen –DR # list of detached screen -xrsh # screen –r PID # attach detached screen ses­sion -xrsh # screen –dmS Myses # start a detached screen ses­sion -xrsh # screen –r MySes #attach screen ses­sion with name MySession -``` - -## Basics - -``` -ctrl a c -> create new window -ctrl a A -> set win­dow name -ctrl a w -> show all win­dow -ctrl a 1|2|3|… -> switch to win­dow n -ctrl a " -> choose win­dow -ctrl a ctrl a -> switch between win­dow -ctrl a d -> detach win­dow -ctrl a ? -> help -ctrl a [ -> start copy, move cur­sor to the copy loca­tion, press ENTER, select the chars, press ENTER to copy the selected char­ac­ters to the buffer -ctrl a ] -> paste from buffer -``` - -## Advanced - -``` -ctrl a S -> cre­ate split screen -ctrl a TAB -> switch between split screens -ctrl a Q -> Kill all regions but the cur­rent one. -ctrl a X -> remove active win­dow from split screen -ctrl a O -> logout active win­dow (dis­able out­put) -ctrl a I -> login active win­dow (enable output) -``` ## webrequests to the filesystem @@ -181,3 +169,43 @@ current [security] limitations: * only /mnt directory is exposed * file needs to be world-readable (`chmod +r /mnt/`) + +# Boot sequence + +The following files are loaded during boot (via `/etc/profile`) + +| file | info | +|-----------------------|---------------------------------------------------| +| /etc/profile.xrsh | sets up xrsh environment | +| /etc/profile.sh | global shellscript functions | +| /etc/profile.js | global javascript functions | +| /mnt/profile.browser | environment vars set by browser (`echo $HOSTNAME`)| +| /root/.profile | user shellscript functions/settings | +| /root/.profile.js | user javascript functions | +| /root/.screenrc | GNU screen initialisations | +| https://.../#ls | URI fragment is executed as command in own screen | + +> TIP: to keep things portable with future versions of XRSH: modify files in `/root/*` + +# Calling terminal from javascript + +```javascript +const term = document.querySelector('[isoterminal]').components.isoterminal.term +term.exec("ls -la") + +// interact directly with files +await term.worker.create_file("hello.txt", term.convert.toUint8Array("hello") ) +await term.worker.update_file("hello.txt", term.convert.toUint8Array("hi") ) +await term.worker.append_file("hello.txt", term.convert.toUint8Array("world") ) +const f = await term.worker.read_file("hello.txt") +``` + +# Calling javascript from terminal + +Various options: + +1. Just add the `#!/bin/js` shebang to the top of a javascript file (+ chmod +x) +2. Run `js "alert('hello')"` in the shell +3. Run `jsh alert hello` in the shell +4. Run `jsh` to start an interactive shell + diff --git a/dist/v86-linux.iso b/dist/v86-linux.iso index e87f80b..c57f91c 100644 Binary files a/dist/v86-linux.iso and b/dist/v86-linux.iso differ