SikuliX on Linux Mint launch scrcpy from SikuliX script

Asked by Mike Praeuner on 2019-09-10

So.... I decided to migrate my SikuliX and scripts from my main system (W10) to an older computer (Linux Mint)
The Mint system has SikuliX latest version, with IDE functional (+ xdotool and wmctrl)
reference: https://sikulix-2014.readthedocs.io/en/latest/newslinux.html
Because it is a older system instead of virtualization of Android I am using SCRCPY (with a tethered Android device) - which is installed via snap and working
reference: https://github.com/Genymobile/scrcpy/blob/master/README.md
I think other than a few adjustments (like the one below) the scripts will transition very well - and let me use my main system again to its full potential

From Terminal I run scrcpy -S

Using the app function in SikuliX what is the syntax to open this program as part of the script?

I also created scrcpy.sh and tried to execute the script, but I am missing something here as well
./scrcpy.sh works from terminal / file manager gui (Home directory) but I am not having any luck getting it to launch from the SikuliX script

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-09-13
Last query:
2019-09-13
Last reply:
2019-09-11
Best RaiMan (raimund-hocke) said : #1

App.run(<command-line-string>)

should work.

the java docs:
 /**
   * the given text is parsed into a String[] suitable for issuing a Runtime.getRuntime().exec(args). quoting is
   * preserved/obeyed. the first item must be an executable valid for the running system.<br>
   * After completion, the following information is available: <br>
   * App.lastRunResult: a string containing the complete result according to the docs of the run() command<br>
   * App.lastRunStdout: a string containing only the output lines that went to stdout<br>
   * App.lastRunStderr: a string containing only the output lines that went to stderr<br>
   * App.lastRunReturnCode: the value, that is returnd as returncode
   *
   * @param cmd the command to run starting with an executable item
   * @return the final returncode of the command execution
   */

It might be necessary, to give the script with its absolute pathname and as executable you might need to use the shell executable (bash I guess in this case).

Mike Praeuner (eris667) said : #2

That got me going in the right direction!

I ended up using:
        app = App.run('gnome-terminal -e "scrcpy -S" &')
# app.open(5)
# reg = app.window(0)

The two commented out lines were from my windows script - they create a error now
App vs App.run

Because scrcpy and sikuli both use the terminal for output I needed to spawn a separate terminal window

Mike Praeuner (eris667) said : #3

Thanks RaiMan, that solved my question.