Skip to content

Commit

Permalink
add support for X11/Qt UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Apr 8, 2020
1 parent cd71c8a commit 84b8c26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 17 additions & 8 deletions src/emuContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class EmuContainer {
this.elfLocalPath = elfLocalPath;
}

async runContainer(logging = false) {
async runContainer(logging, X11) {
return new Promise((resolve, reject) => {
// eslint-disable-next-line global-require
const Docker = require("dockerode");
Expand All @@ -36,8 +36,20 @@ export default class EmuContainer {
const app_filename = path.basename(this.elfLocalPath);
const app_dir = path.dirname(this.elfLocalPath);

const appPathBinding = `${app_dir}:${DEFAULT_APP_PATH}`;
const command = `/home/zondax/speculos/speculos.py --display headless --vnc-port ${DEFAULT_VNC_PORT} ${DEFAULT_APP_PATH}/${app_filename}`;
let displaySetting = "--display headless"
if (X11) {
displaySetting = ""
}

const command = `/home/zondax/speculos/speculos.py ${displaySetting} --vnc-port ${DEFAULT_VNC_PORT} ${DEFAULT_APP_PATH}/${app_filename}`;

let dirBindings = [
`${app_dir}:${DEFAULT_APP_PATH}`
]

if (X11) {
dirBindings.push("/tmp/.X11-unix:/tmp/.X11-unix:ro")
}

docker.createContainer({
Image: this.image,
Expand All @@ -50,7 +62,7 @@ export default class EmuContainer {
`SCP_PRIVKEY=${SCP_PRIVKEY}`,
`BOLOS_SDK=${BOLOS_SDK}`,
`BOLOS_ENV=/opt/bolos`,
// `DISPLAY=:0`, //needed if X forwarding
`DISPLAY=${process.env.DISPLAY}`, //needed if X forwarding
],
PortBindings: {
[`1234/tcp`]: [{ HostPort: "1234" }],
Expand All @@ -59,10 +71,7 @@ export default class EmuContainer {
[`9998/tcp`]: [{ HostPort: "9998" }],
[`9999/tcp`]: [{ HostPort: "9999" }],
},
Binds: [
appPathBinding,
// `/tmp/.X11-unix:/tmp/.X11-unix` //needed if X forwarding
],
Binds: dirBindings,
Cmd: [
command,
],
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export default class Zemu {
this.emuContainer = new EmuContainer(this.elfPath, DEFAULT_EMU_IMG);
}

async start(logging = false) {
await this.emuContainer.runContainer(logging);
async start(logging = false, x11 = false) {
await this.emuContainer.runContainer(logging, x11);
// eslint-disable-next-line func-names
await this.connect().catch(error => {
console.log(error);
Expand Down

0 comments on commit 84b8c26

Please sign in to comment.