-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
41 lines (34 loc) · 1.08 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {LinuxBrowserShell} from "linux-browser-shell"
const shell = new LinuxBrowserShell(
{
wasm: "./v86/v86.wasm",
bios: "./v86/seabios.bin",
vga_bios: "./v86/vgabios.bin",
cdrom: "./v86/image.iso",
initial_state: "./v86/initial-state.bin.zst",
font: "monospace",
},
document.getElementById("screen"),
)
let tty0 = shell.getTerminal(0)
let tty1 = shell.getTerminal(1)
tty0.attach(document.getElementById("terminal0"))
tty1.attach(document.getElementById("terminal1"))
shell.boot().then(() => {
console.log("Booted")
})
// Save state of the VM. You can then later load it using the `initial_state` setting.
document.getElementById("save").onclick = async function () {
shell.downloadState()
}
// Demonstrate how to send commands to a Terminal.
// You can use this in the developer console, using `run("uname -a")` for example.
window.run = (cmd) => {
tty0.run(cmd).then((res) => {
console.log(res)
})
}
// Demonstrate how to listen for user commands.
tty0.onUserCommand(() => {
console.log("User ran a command")
})