Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add support for linux #1

Open
YouROK opened this issue Jul 20, 2020 · 4 comments
Open

Please add support for linux #1

YouROK opened this issue Jul 20, 2020 · 4 comments

Comments

@YouROK
Copy link

YouROK commented Jul 20, 2020

private void launchScrcpy(String mirrorPath, Project project)
    {
        VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(mirrorPath));
        if (file == null) {
            JOptionPane.showMessageDialog(null, "The selected file maybe moved or removed. \n\nSelect the path again by Tools -> Side Mirror -> Choose Mirror Path option.", "Error", JOptionPane.ERROR_MESSAGE);
            showChoosePathDialog(project);
            return;
        }

        String[] cmd = { mirrorPath };
        try {
            if (OsUtils.getOperatingSystemType() == OsUtils.OSType.Windows)
            {
                Process p = Runtime.getRuntime().exec(cmd);
            }
        else if (OsUtils.getOperatingSystemType() == OsUtils.OSType.MacOS)
        {
            ProcessBuilder processBuilder = new ProcessBuilder("open", mirrorPath);
            Process p = processBuilder.start();
            int exitCode = p.waitFor();
        }
        else if (OsUtils.getOperatingSystemType() == OsUtils.OSType.Linux)
        {
            ProcessBuilder processBuilder = new ProcessBuilder("bash", "-c", mirrorPath);
            Process p = processBuilder.start();
            p.waitFor();
        }
        else
        {
            JOptionPane.showMessageDialog(null, "Side Mirror is not supported on your OS currently.", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
    catch (IOException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "The selected file seems not be the correct type. \n\nSelect the path again by Tools -> Side Mirror -> Choose Mirror Path option.", "Error", JOptionPane.ERROR_MESSAGE);
        showChoosePathDialog(project);
    } catch (InterruptedException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "The selected file seems not be the correct type. \n\nSelect the path again by Tools -> Side Mirror -> Choose Mirror Path option.", "Error", JOptionPane.ERROR_MESSAGE);
        showChoosePathDialog(project);
    }
}
@wajahatkarim3
Copy link
Owner

Thank you for the code. Can you help me test it out as I don't have Linux?

@YouROK
Copy link
Author

YouROK commented Aug 3, 2020

Yes of course? But I don't compile plugin for test

@wajahatkarim3
Copy link
Owner

Let me update this code on Intellij Plugins and then you can test it and let me know if it works or not.

@YouROK
Copy link
Author

YouROK commented Aug 3, 2020

Lets go, I'm ready for test)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants