Electron: starting terminal in main window - node.js

I'm using something like
child_process.exec('start cmd.exe /K bash -c "some commands..."')
to start a terminal. Everything works fine. Of course the terminal opens as a separate window. Is there a way to embed this terminal in the main app window?

There are probably multiple ways to achieve this. One would be using something like xterm. Microsoft Visual Studio Code uses it I believe.
From their description:
Xterm.js is a terminal front-end component written in JavaScript that
works in the browser.
It enables applications to provide fully featured terminals to their
users and create great development experiences.

Related

Cocoa = How to run script in background without launching terminal in C

In my Cocoa Application, I am running a script by using c functions like setenv() and popen(). It executes the script perfectly. But the issue is, At runtime, popen() opens the Terminal app and after the script is executed, It closes the Terminal app automatically. I want to execute the script without opening the Terminal app.
I found a solution to use NSAppleScript. But This class is available only in Foundation, but not available in Core Foundation. I want the same feature to be written in C. How to achieve this.
Please advice.
Use NSTask to execute the script. This allows you to have it run in background while still being able to specify environment variables, monitor output, etc.

Can I deactivate a monitor/display with node/electron?

I, I'm writing an app with electron (http://electron.atom.io/). I would like to deactivate the monitor/display of the pc and only activate it again, when something in the app happens (for energy-saving). Is there a way to do this?
The only think I found, is the powerSaveBlocker (http://electron.atom.io/docs/api/power-save-blocker/) which doesn't help me...
You'll need to use native system APIs to do this, on Windows you can use one of the solutions proposed in Turn on/off monitor.
One of the ways you can do that is by executing batch files from electron/node in Windows , shell scripts in Linux and whatever MAC OS uses to execute commands.
These scripts would contain the OS level commands to turn on/off the display which are easily available .
When to fire these scripts would depend on your application logic .

executing a desktop app in linux by command line without showing its GUI window

I have an windowed App (f.i. an App with a graphic or GUI X-window) which takes a text file as input (stdin) and writes an output text file. During computation, it briefly opens a window which is necessary for graphical computations and then the app quits. How can I integrate this program in a purely textual and automated batch environment of a shell in linux? When I try to just run it in the shell then of course I get an error "Can't open display".
Is there a way to keep the APP window hidden such that it can run purely in the shell?
(in my case it is actually an AIR app, but I hope this is solvable in general for all kinds of xwindow-based apps)
Seems I can answer my own question. The answer is: Xvfb. It provides a 'fake' virtual framebuffer.
In Ubuntu linux I did:
apt-get install xvfb
After installation a xvfb-run wrapper script became available which does exactly what I need:
xvfb-run myapp
Perfect!

Running a GUI app on linux, without showing the gui?

I'm working with an api that requires an app to be started, the app runs a GUI on linux.
I need to punsh in some login information and then hide the app.
Is there a way I can go to the machine start the GUI and then hide it, log out, and have other users log in with out having the GUI shown, but still having the app running?
You can take a look at Xvfb http://en.wikipedia.org/wiki/Xvfb
it's a framebuffer version of X.
It will launch an X11 server without displaying it (useful with selenium for example)
Xdotool can send input to anyb xwindow, including xvfb

How can I control in which of my desktops the browser called by selenium remote server will pop up?

I am running tests from phpunit using selenium. Since the tests take a couple of minutes proceed, I would like to switch to another desktop and do some tasks while the tests are running in the background.
However, since every test calls a new browser via selenium remote server, and a new test management window and a application window are started, these new windows do not appear in the desktop which I started the php tests from, but in my current desktop taking the focus away from the window I am working in.
How can I control that the browsers are always opens in the desktop that is in the background (where I start phpunit)? I am using Kubuntu i.e. the KDE Desktop.
Thanks for any suggestions!
This is probably a bit late, but for anyone reading this: When you launch your selenium RC server, you could try exporting to a specific display using the command:
export DISPLAY="somedisplay" && java -jar /path/to/selenium-server.jar
Using this, you could also export it to for instance an X virtual frame buffer (Xvfb), effectively running it in the background.

Resources