fixed terminal open
This commit is contained in:
parent
ac13e6504f
commit
c132811c0b
@ -1058,7 +1058,7 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String osName = System.getProperty("os.name").toLowerCase();
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
ProcessBuilder pb;
|
ProcessBuilder pb = null;
|
||||||
|
|
||||||
if (osName.contains("win")) {
|
if (osName.contains("win")) {
|
||||||
// Windows
|
// Windows
|
||||||
@ -1068,15 +1068,20 @@ public class MainWindow extends JFrame {
|
|||||||
pb = new ProcessBuilder("open", "-a", "Terminal", currentDir.getAbsolutePath());
|
pb = new ProcessBuilder("open", "-a", "Terminal", currentDir.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
// Linux and other Unix-like systems
|
// Linux and other Unix-like systems
|
||||||
// Try common terminal emulators
|
// Try common terminal emulators with working directory arguments
|
||||||
String[] terminals = {"gnome-terminal", "xterm", "konsole", "xfce4-terminal", "mate-terminal"};
|
String[] terminals = {"gnome-terminal", "konsole", "xfce4-terminal", "mate-terminal", "xterm"};
|
||||||
pb = null;
|
|
||||||
|
|
||||||
for (String terminal : terminals) {
|
for (String terminal : terminals) {
|
||||||
try {
|
try {
|
||||||
Process p = Runtime.getRuntime().exec(new String[]{"which", terminal});
|
Process p = Runtime.getRuntime().exec(new String[]{"which", terminal});
|
||||||
if (p.waitFor() == 0) {
|
if (p.waitFor() == 0) {
|
||||||
pb = new ProcessBuilder(terminal);
|
if (terminal.equals("gnome-terminal") || terminal.equals("xfce4-terminal") || terminal.equals("mate-terminal")) {
|
||||||
|
pb = new ProcessBuilder(terminal, "--working-directory=" + currentDir.getAbsolutePath());
|
||||||
|
} else if (terminal.equals("konsole")) {
|
||||||
|
pb = new ProcessBuilder(terminal, "--workdir", currentDir.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
pb = new ProcessBuilder(terminal);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1085,13 +1090,15 @@ public class MainWindow extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pb == null) {
|
if (pb == null) {
|
||||||
// Fallback to xterm if nothing else works
|
// Fallback to xterm
|
||||||
pb = new ProcessBuilder("xterm");
|
pb = new ProcessBuilder("xterm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pb.directory(currentDir);
|
if (pb != null) {
|
||||||
pb.start();
|
pb.directory(currentDir);
|
||||||
|
pb.start();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
JOptionPane.showMessageDialog(this,
|
JOptionPane.showMessageDialog(this,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user