main: work in progress [might break]
This commit is contained in:
parent
928512ba64
commit
2222061c0b
|
@ -1 +0,0 @@
|
|||
dist/
|
10
README.md
10
README.md
|
@ -77,6 +77,14 @@ We define a `v86` buildroot "board" via the following files and directories:
|
|||
|
||||
If you need or want to update these config files, do the following:
|
||||
|
||||
## method 1 (auto-guide via shellscript)
|
||||
|
||||
```
|
||||
$ ./build.sh --edit
|
||||
```
|
||||
|
||||
## method 2 (manually)
|
||||
|
||||
```bash
|
||||
$ make BR2_EXTERNAL=/buildroot-v86 v86_defconfig
|
||||
$ make menuconfig
|
||||
|
@ -85,6 +93,8 @@ $ make savedefconfig
|
|||
$ make linux-menuconfig
|
||||
...
|
||||
$ make linux-savedefconfig
|
||||
$ mkdir output/legal-info && touch output/legal-info/{host-licenses,licenses,buildroot.config}
|
||||
$ make
|
||||
```
|
||||
|
||||
## Configuration Notes
|
||||
|
|
14
build.sh
14
build.sh
|
@ -1,12 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker build -t buildroot .
|
||||
test "$1" = "--edit" && {
|
||||
EDIT="-ti -v $PWD/edit.sh:/root/edit.sh --entrypoint bash"
|
||||
}
|
||||
#-v $PWD/cache:/root/buildroot-2021.02-rc2/output
|
||||
|
||||
|
||||
test -d dist || mkdir dist
|
||||
test -d cache || mkdir cache
|
||||
rm -rf cache/*
|
||||
|
||||
docker images | grep buildroot || docker build -t buildroot .
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
--name build-v86 \
|
||||
-v $PWD/dist:/build \
|
||||
-v $PWD/buildroot-v86/:/buildroot-v86 \
|
||||
-v $PWD/buildroot-v86/:/buildroot-v86 ${EDIT} \
|
||||
buildroot
|
||||
|
||||
echo "See ./dist for built ISO"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
[38;5;93m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
[38;5;57m . . ____ _____________ ________. ._. ._. . . . . . . . .
|
||||
[38;5;93m . . _\ \/ /\______ \/ _____// | \. . . . . . . .
|
||||
[38;5;93m . . _ \ / | _/\_____ \/ ~ \ . . . . . . .
|
||||
[38;5;129m _ _ / \ | | \/ \ Y / _ _ _ _ _ _ _
|
||||
[38;5;165m . . /___/\ \ |____|_ /_______ /\___|_ /. . . . . . . .
|
||||
[38;5;201m . . . . . .\_/. . . . \/ . . . .\/ . . _ \/ . . . . . . . .
|
||||
[38;5;165m ▬▬▬▬ https://xrsh.isvery.ninja ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
|
||||
|
||||
[38;5;165mOpen, local-first, unix hackable & selfcontained XR apps.
|
||||
|
||||
credits: NLnet | @nlnet@nlnet.nl https://nlnet.nl/project
|
||||
all FOSS devs | copy.sh (v86) aframe.io (AFRAME)
|
||||
Leon van Kammen | @lvk@mastodon.online
|
||||
Fabien Benetou | @utopiah@mastodon.pirateparty.be
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# source URL data from v86 (file created by v86 during boot)
|
||||
test -f /etc/profile.browser && source /etc/profile.browser
|
||||
|
||||
# source xrsh env
|
||||
source /etc/profile.xrsh
|
||||
|
||||
# source shell functions
|
||||
source /etc/profile.sh
|
||||
|
||||
# source js functions
|
||||
./.profile.js
|
||||
|
||||
## forward not-found commands to javascript (via jsh)
|
||||
command_not_found_handle(){
|
||||
echo "[!] '$1' not found, did you mean $1(...) (javascript?)"
|
||||
test -n "$ONBOARDING" && echo "[i] type 'help' for handy commands"
|
||||
test -n "$ONBOARDING" || help
|
||||
}
|
||||
|
||||
help(){
|
||||
echo ""
|
||||
echo 'TIPS'
|
||||
echo '----'
|
||||
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 disable: ' "type 'echo 0 > /dev/browser/console.tty' to enable"
|
||||
echo 'js capture console: ' "type 'tail -f /dev/browser/console'"
|
||||
echo 'jsh<->sh hooks: ' "type 'chmod +x ~/hook.d/*/* && alert helloworld'"
|
||||
echo 'include file into page' "type 'require <url.js|css>'"
|
||||
echo 'create AFRAME a-entity' "type 'a_entity <componentname> [...]"
|
||||
echo ''
|
||||
echo 'type "man -l /root/manual.md" to read the full manual"'
|
||||
ONBOARDING=1
|
||||
}
|
||||
|
||||
resize
|
||||
test $HOSTNAME = localhost || clear
|
||||
cat /etc/motd
|
||||
export PATH=$PATH:/etc:~/bin
|
||||
export TERM=xterm-256color
|
||||
export PS1="\n\[\033[38;5;57m\]x\[\033[38;5;93m\]r\[\033[38;5;129m\]s\[\033[38;5;165m\]h \[\033[38;5;201m\]# \[\033[0m\]"
|
||||
|
||||
pidof screen || screen -T screen-256color -c /root/.screenrc
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/js
|
||||
|
||||
window.helloworld = function(){
|
||||
alert("hello world")
|
||||
return "hello world"
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
hook(){
|
||||
test -z "$1" && { echo "usage: hook <cmd_or_jsfunction> [args]"; return 0; }
|
||||
cmd=$1
|
||||
shift
|
||||
test -d ~/hook.d/$cmd && {
|
||||
find ~/hook.d/$cmd/ -type f -executable | while read hook; do
|
||||
{ $hook "$@" || true; } | awk '{ gsub(/\/root\/\//,"",$1); $1 = sprintf("%-40s", $1)} 1'
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
alert(){
|
||||
test -z "$1" && { echo "usage: alert <title> <message>"; return 0; }
|
||||
title=$1
|
||||
test -z "$1" || shift
|
||||
msg="$*"
|
||||
printf "[38;5;165m%s \033[0m%s\n" "$title" "$msg"
|
||||
hook alert $title "$msg"
|
||||
}
|
||||
|
||||
confirm(){
|
||||
test -z "$1" && { echo "usage: confirm <question>"; return 0; }
|
||||
read -p "$(printf "\033[0m")[?] [38;5;165m$1 [y/n] $(printf "\033[0m")" y
|
||||
test $y = y && echo true && return 0
|
||||
test $y = y || echo false
|
||||
hook confirm $1 $y
|
||||
}
|
||||
|
||||
prompt(){
|
||||
test -z "$1" && { echo "usage: prompt <question> [answer_default]"; return 0; }
|
||||
test -n "$2" && answer="[$2] " && answer_fallback="$2"
|
||||
read -p "$(printf "\033[0m")[?] [38;5;165m$1: $answer $(printf "\033[0m")" answer
|
||||
test -z "$answer" && answer="$answer_fallback"
|
||||
echo "$answer"
|
||||
hook prompt $1 $answer
|
||||
}
|
||||
|
||||
console(){
|
||||
js 'return '$1
|
||||
}
|
||||
|
||||
require(){
|
||||
file=$(basename "$1")
|
||||
js '(async () => {
|
||||
await AFRAME.utils.require({"'$file'": "'$1'"})
|
||||
})()'
|
||||
}
|
||||
|
||||
a_entity(){
|
||||
code="let el = document.createElement('a-entity')"
|
||||
for i in "$@"; do
|
||||
code="$code;\nel.setAttribute('$i','')\n";
|
||||
done
|
||||
code="document.querySelector('a-scene').appendChild(el)"
|
||||
echo "$code"
|
||||
js "$code"
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh
|
||||
|
||||
test -d /dev/browser || {
|
||||
|
||||
setup_binaries(){
|
||||
for bin in /mnt/js* /mnt/v86pipe /mnt/xrsh; do
|
||||
chmod +x $bin
|
||||
ln -s $bin /bin/.
|
||||
done
|
||||
}
|
||||
|
||||
setup_links(){
|
||||
ln -s /mnt/profile ~/.profile
|
||||
ln -s /mnt/profile.js ~/.profile.js
|
||||
ln -s /mnt/profile.browser ~/.profile.browser
|
||||
ln -s /mnt/profile.sh ~/.profile.sh
|
||||
ln -s /mnt/motd ~/.motd
|
||||
ln -s ~/.profile.js ~/index.js
|
||||
chmod +x ~/.profile.js
|
||||
}
|
||||
|
||||
setup_browser_dev(){
|
||||
mkdir -p /mnt/dev/browser
|
||||
touch /mnt/dev/browser/js
|
||||
touch /mnt/console.tty
|
||||
ln -s /mnt/dev/browser /dev/browser
|
||||
# emulator.write_file() only writes to /mnt/. :(
|
||||
# should be in /proc, but v86 gives 'no such file or dir' when creating it there
|
||||
ln -s /mnt/console.tty /dev/browser/console.tty
|
||||
echo 1 > /dev/browser/console.tty
|
||||
touch /mnt/console && ln -s /mnt/console /dev/browser/console
|
||||
touch /mnt/index.html && ln -s /mnt/index.html /dev/browser/index.html
|
||||
ln -s /dev/browser/index.html ~/index.html
|
||||
|
||||
test -f /etc/profile && rm /etc/profile
|
||||
ln -s /mnt/profile /etc/profile
|
||||
}
|
||||
|
||||
setup_hook_dirs(){ # see /mnt/hook for usage
|
||||
mkdir ~/bin
|
||||
mkdir -p ~/hook.d/alert
|
||||
echo -e "#!/bin/sh\necho hook.d/alert/yo: yo \$*" > ~/hook.d/alert/yo
|
||||
echo -e "#!/bin/js\nstr = \"hook.d/alert/yo.js yo \"+args.slice(1).join(' ')\nalert(str)\nreturn str" > ~/hook.d/alert/yo.js
|
||||
echo -e "#!/usr/bin/env lua\nprint(\"hook.d/alert/yo.lua: yo \" .. arg[1])" > ~/hook.d/alert/yo.lua
|
||||
echo -e "#!/usr/bin/awk -f\nBEGIN{\n\tprint \"hook.d/alert/yo.awk: yo \" ARGV[1]\n}" > ~/hook.d/alert/yo.awk
|
||||
echo -e "#!/bin/sh\necho hello \$*" > ~/bin/hello
|
||||
chmod +x ~/bin/hello
|
||||
}
|
||||
|
||||
setup_network(){
|
||||
test -n "$BROWSER" || return 0
|
||||
#mount -a
|
||||
udhcpc 1>>/var/log/network.log 2>>/var/log/network.log &
|
||||
echo 0 > /proc/sys/kernel/printk
|
||||
}
|
||||
|
||||
setup_binaries
|
||||
setup_browser_dev
|
||||
setup_hook_dirs
|
||||
setup_links
|
||||
setup_network
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
# look and feel
|
||||
#caption always "%{i0}^{=}" #"%{= bb}%n%{+b w}%t %{= db} ${USER}@xrsh.iso"
|
||||
#hardstatus alwayslastline "%-Lw%{= BW} %{=B}%t%{-B} %{-}%+Lw%<"
|
||||
#caption always "%{= bb}%{+b w}%n %t %h %=%l %H %c"
|
||||
hardstatus alwayslastline "%{= Bb}%-Lw%{= BW}%50> %t %{-}<"
|
||||
|
||||
# skip the startup message
|
||||
startup_message off
|
||||
|
||||
# go to home dir
|
||||
chdir
|
||||
|
||||
# Automatically detach on hangup.
|
||||
autodetach on
|
||||
|
||||
# Change default scrollback value for new windows
|
||||
defscrollback 10000
|
||||
|
||||
# start with visual bell as default
|
||||
vbell on
|
||||
vbell_msg "bell on %t (%n)"
|
||||
|
||||
|
||||
bind x # Do not lock screen
|
||||
bind ^x # Idem
|
||||
|
||||
activity "activity in %t(%n)"
|
||||
|
||||
shelltitle "xrsh"
|
||||
shell -$SHELL
|
||||
|
||||
# correct colors
|
||||
attrcolor b ".I" # allow bold colors - necessary for some reason
|
||||
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' # tell screen how to set colors. AB = background, AF=foreground
|
||||
term xterm-256color
|
||||
defbce on # use current bg color for erased chars
|
||||
|
||||
# setup windows
|
||||
screen -t jsconsole 0 tail -f /dev/browser/console
|
||||
screen -t xrsh 1
|
||||
If you want it to start with a particular window active, you can add a line like the following:
|
||||
|
||||
select 1
|
|
@ -0,0 +1 @@
|
|||
bar
|
|
@ -0,0 +1,39 @@
|
|||
XRSH Manual
|
||||
===========
|
||||
|
||||
# Multiple terminals [GNU screen]
|
||||
|
||||
## From the cmdline
|
||||
|
||||
```
|
||||
xrsh # screen –DR # list of detached screen
|
||||
xrsh # screen –r PID # attach detached screen session
|
||||
xrsh # screen –dmS Myses # start a detached screen session
|
||||
xrsh # screen –r MySes #attach screen session with name MySession
|
||||
```
|
||||
|
||||
## Basics
|
||||
|
||||
```
|
||||
ctrl a c -> create new window
|
||||
ctrl a A -> set window name
|
||||
ctrl a w -> show all window
|
||||
ctrl a 1|2|3|… -> switch to window n
|
||||
ctrl a " -> choose window
|
||||
ctrl a ctrl a -> switch between window
|
||||
ctrl a d -> detach window
|
||||
ctrl a ? -> help
|
||||
ctrl a [ -> start copy, move cursor to the copy location, press ENTER, select the chars, press ENTER to copy the selected characters to the buffer
|
||||
ctrl a ] -> paste from buffer
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
```
|
||||
ctrl a S -> create split screen
|
||||
ctrl a TAB -> switch between split screens
|
||||
ctrl a Q -> Kill all regions but the current one.
|
||||
ctrl a X -> remove active window from split screen
|
||||
ctrl a O -> logout active window (disable output)
|
||||
ctrl a I -> login active window (enable output)
|
||||
```
|
|
@ -0,0 +1 @@
|
|||
#
|
Loading…
Reference in New Issue