finetuned shell-env + codemirror + added filemanager

This commit is contained in:
Leon van Kammen 2024-09-23 17:53:59 +02:00
parent 04b5621249
commit b3cdc74578
12 changed files with 2375 additions and 21 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,5 +17,6 @@
Please hook up your (bluetooth) keyboard to use xrsh. Please hook up your (bluetooth) keyboard to use xrsh.
Use Ctrl+a+0/1/2/3/.. to switch terminals. Use Ctrl+a+0/1/2/3/.. to switch terminals.
Use Ctrl+a+c to create a new terminal. Use Ctrl+a+c to create a new terminal.
Use 'save' to save session (survives tab-close)
Happy hacking! \o/ Happy hacking! \o/

View File

@ -37,15 +37,22 @@ prompt(){
console(){ console(){
js 'return '$1 js 'return '$1
printf "\n"
} }
# usage: require <url|file>
#
# info: adds javascript/css url/script to DOM
require(){ require(){
file=$(basename "$1") file=$(basename "$1")
js '(async () => { js '(async () => {
await AFRAME.utils.require({"'$file'": "'$1'"}) await AFRAME.utils.require({"'$file'": "'$1'"})
})()' })(); return ""'
} }
# usage: man <topic>
#
# info: simple manual viewer
man(){ man(){
test "$1" = xrsh && { test "$1" = xrsh && {
cat /root/manual.md | less cat /root/manual.md | less
@ -53,8 +60,23 @@ man(){
} }
help(){ man xrsh; } help(){ man xrsh; }
# usage: infinite ./runmydaemon
#
# info: will run daemon forever (restarts when quit)
infinite(){ infinite(){
while sleep 1s; do while sleep 1s; do
"$@" "$@"
done done
} }
# usage: wait_for sleep 5s
#
# info: will print dots while waiting for process to end
wait_for(){
dotting(){ while sleep 1s; do printf "."; done; }
dotting &
PID=$!
"$@"
kill -9 $PID
printf "\n"
}

View File

@ -2,6 +2,12 @@
test -d /dev/browser || { test -d /dev/browser || {
move_root_to_9pfs(){
test -d /mnt/root && return 0
mv /root /mnt/.
ln -fs /mnt/root /root
}
setup_links(){ setup_links(){
ln -fs /etc/motd ~/.motd ln -fs /etc/motd ~/.motd
ln -fs /mnt/profile.browser ~/.profile.browser ln -fs /mnt/profile.browser ~/.profile.browser
@ -37,21 +43,22 @@ test -d /dev/browser || {
cat /dev/ttyS1 | xargs -I{} /bin/sh -c 'source /etc/profile; logger "isoterminal.exec({})"; {}' cat /dev/ttyS1 | xargs -I{} /bin/sh -c 'source /etc/profile; logger "isoterminal.exec({})"; {}'
} }
setup_reflect_index_html(){ setup_listen_homedir(){
# listen for writes to index.html and send them to DOM sleep 4 # wait for inode of /mnt/root to become live (due to move_root_to_9pfs)
inotifyd echo /root/index.html | awk '/^w / { system("cat "$2" | grep -vE \"^#!\" > /dev/browser/html") }' inotifyd echo /mnt/root | awk '
}
# listen for writes to rootdir and send them to DOM
setup_reflect_index_js(){ /^[we] \/mnt\/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") }
# listen for writes to index.js and send them to DOM /^[we] \/mnt\/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") }
inotifyd echo /root/index.js | awk '/^w / { system("cat "$2" | grep -vE \"^#!\" > /dev/browser/js") }'
'
} }
move_root_to_9pfs
setup_browser_dev setup_browser_dev
setup_links setup_links
setup_network setup_network
setup_overlayfs setup_overlayfs
setup_incoming_cmds & setup_incoming_cmds &
setup_reflect_index_html & setup_listen_homedir &
setup_reflect_index_js &
} }

View File

@ -33,6 +33,6 @@ term xterm-256color
defbce on # use current bg color for erased chars defbce on # use current bg color for erased chars
# setup windows # setup windows
screen -t manual 0 /bin/sh -c '/bin/infinite help' screen -t manual 0 /bin/sh --noprofile --norc -c '/bin/infinite help'
screen -t logs 1 /bin/sh -c '/bin/infinite tail -n1 -f /dev/browser/console /var/log/messages' screen -t logs 1 /bin/sh --noprofile --norc -c '/bin/infinite tail -n1 -f /dev/browser/console /var/log/messages'
screen -t xrsh 2 screen -t xrsh 2

View File

@ -1,4 +1,25 @@
#!/bin/sh #!/bin/js
source /etc/profile.sh
require 'com/codemirror.js' # add <script src="com/codemirror.js"></script> to dom (async function(){
echo '<a-entity codemirror grabbable></a-entity>' >> /dev/browser/html
await AFRAME.utils.require({
codemirrorjs: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js",
codemirrorcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css",
cmtheme: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css"
})
await AFRAME.utils.require({
cmxml: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/xml/xml.js",
cmjavascript: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/javascript/javascript.js",
cmcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/css/css.js",
highlight: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/htmlmixed/htmlmixed.js",
codemirrorAF: "com/codemirror.js"
})
document.querySelector("a-entity#root").innerHTML += `<a-entity codemirror='file: ${args[1]}'></a-entity>`
})()
return "" // empty stdout(put)
// for shellscript-equivalent see bin/codemirror

View File

@ -0,0 +1,11 @@
#!/bin/sh
source /etc/profile.sh
require 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js'
require 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css'
require 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css'
require 'com/codemirror.js'
echo "<a-entity codemirror='file: $1'></a-entity>" >> /dev/browser/html
# for js-equivalent see bin/codemirror

View File

@ -1,4 +1,13 @@
#!/bin/js #!/bin/sh
const isoterminal = document.querySelector('[isoterminal]').components.isoterminal.isoterminal source /etc/profile.sh
javascript='
const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.isoterminal
isoterminal.save() isoterminal.save()
return "[OK] xrsh state saved\n" return "[OK] xrsh state saved\n"
'
echo "[OK] triggering ~/hook.d/save/* scripts"
hook save
echo "[..] please wait.."
js "$javascript"

View File

@ -0,0 +1,2 @@
#!/bin/js
// /bin/filemanager => browser play mp3

View File

@ -0,0 +1,3 @@
#!/bin/sh
echo "[OK] hook.d/save/tolog: reporting save to OS"
logger "state was saved at $(date)"

File diff suppressed because it is too large Load Diff

BIN
dist/v86-linux.iso vendored

Binary file not shown.