Skip to content

Commit

Permalink
fix: xfce4-terminal uses the -x command-line arg instead of -e
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Dec 18, 2022
1 parent a305c58 commit 92ca37a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changes in unreleased:
- Mac: bundle Java 17 runtime, so that Java doesn't need to be installed separately
- Mac: change next alive host shortcut to Cmd+N (Cmd+H is conflicting with hide window)
- Windows installer: update bundled Java runtime to 17
- Linux XFCE: execute terminal properly #379

Changes in 3.8.2:
- Allow building if .git is not present (e.g. from source zip) #319
Expand Down
10 changes: 5 additions & 5 deletions src/net/azib/ipscan/gui/actions/TerminalLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -38,7 +37,7 @@ public static void launchInTerminal(String execString, File workingDir) {
try {
if (Platform.WINDOWS) {
// generate a command file :-)
File batFile = File.createTempFile("launch", ".cmd");
var batFile = File.createTempFile("launch", ".cmd");
batFile.deleteOnExit();
try (FileWriter writer = new FileWriter(batFile)) {
writer.write("@rem This is a temporary file generated by Angry IP Scanner\n" +
Expand All @@ -52,9 +51,10 @@ else if (Platform.MAC_OS) {
}
else { // assume Linux
if (workingTerminal == null) workingTerminal = detectWorkingTerminal();
String shell = System.getenv("SHELL");
var shell = System.getenv("SHELL");
if (shell == null) shell = "sh";
Runtime.getRuntime().exec(new String[] {workingTerminal, "-e", shell, "-xc", execString + ";" + shell}, null, workingDir);
var execArg = workingTerminal.contains("gnome") || workingTerminal.contains("xfce") ? "-x" : "-e";
Runtime.getRuntime().exec(new String[] {workingTerminal, execArg, shell, "-xc", execString + ";" + shell}, null, workingDir);
}
}
catch (Exception e) {
Expand All @@ -66,7 +66,7 @@ else if (Platform.MAC_OS) {

private static String detectWorkingTerminal() {
for (String term : asList("x-terminal-emulator", "xdg-terminal", "gnome-terminal", "xfce4-terminal", "konsole", "xterm")) {
File file = new File("/usr/bin/" + term);
var file = new File("/usr/bin/" + term);
if (file.exists()) return file.getPath();
}
return "xterm";
Expand Down

0 comments on commit 92ca37a

Please sign in to comment.