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