mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-26 18:35:43 +00:00
Rework [stage]
This commit is contained in:
@@ -22,7 +22,7 @@ public interface AppLocations {
|
||||
}
|
||||
|
||||
private static Path parsePath(String path) {
|
||||
if (path == null) {
|
||||
if (path == null || path.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,24 @@ public interface AppLocations {
|
||||
|
||||
private Path userHome;
|
||||
|
||||
public Path getTemp() {
|
||||
var env = AppLocations.parsePath(System.getenv("TEMP"));
|
||||
if (env == null) {
|
||||
env = AppLocations.parsePath(System.getenv("TMP"));
|
||||
}
|
||||
|
||||
if (env == null) {
|
||||
return getLocalAppData().resolve("Temp");
|
||||
}
|
||||
|
||||
// Don't use system temp dir
|
||||
if (env.startsWith(Path.of("C:\\Windows"))) {
|
||||
return getLocalAppData().resolve("Temp");
|
||||
}
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
public Path getProgramFiles() {
|
||||
var env = AppLocations.parsePath(System.getenv("ProgramFiles"));
|
||||
if (env != null) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class AppRestart {
|
||||
: AppInstallation.ofCurrent();
|
||||
var suffix = (arguments.size() > 0 ? " " + String.join(" ", arguments) : "");
|
||||
if (OsType.getLocal() == OsType.LINUX) {
|
||||
return "nohup \"" + loc.getDaemonExecutablePath() + "\"" + suffix + " 2>&1 & disown";
|
||||
return "nohup \"" + loc.getDaemonExecutablePath() + "\"" + suffix + " </dev/null >/dev/null 2>&1 & disown";
|
||||
} else if (OsType.getLocal() == OsType.MACOS) {
|
||||
return "(sleep 1;open \"" + loc.getBaseInstallationPath() + "\" --args" + suffix
|
||||
+ " </dev/null &>/dev/null) & disown";
|
||||
|
||||
@@ -42,6 +42,8 @@ public class AppSid {
|
||||
return;
|
||||
}
|
||||
|
||||
if (true) return;
|
||||
|
||||
try {
|
||||
// If there is no setsid command, we can't fully prevent commands from accessing any potential parent tty
|
||||
// We can however set the pid to prevent this happening when launched from the cli command
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.core.check;
|
||||
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.core.OsType;
|
||||
|
||||
@@ -33,7 +34,6 @@ public class AppTempCheck {
|
||||
return;
|
||||
}
|
||||
|
||||
checkTemp(System.getProperty("java.io.tmpdir"));
|
||||
checkTemp(System.getenv("TEMP"));
|
||||
checkTemp(AppLocations.getWindows().getTemp().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.prefs;
|
||||
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.ext.PrefsChoiceValue;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
@@ -74,7 +75,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("VSCodium")
|
||||
.resolve("bin")
|
||||
@@ -107,7 +108,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("cursor")
|
||||
.resolve("Cursor.exe"))
|
||||
@@ -139,7 +140,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("PROGRAMFILES"))
|
||||
return Optional.of(AppLocations.getWindows().getProgramFiles()
|
||||
.resolve("Void")
|
||||
.resolve("Void.exe"))
|
||||
.filter(path -> Files.exists(path));
|
||||
@@ -170,7 +171,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("Windsurf")
|
||||
.resolve("bin")
|
||||
@@ -203,7 +204,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("Kiro")
|
||||
.resolve("bin")
|
||||
@@ -237,7 +238,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("TheiaIDE")
|
||||
.resolve("TheiaIDE.exe"))
|
||||
@@ -269,7 +270,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("Trae")
|
||||
.resolve("bin")
|
||||
@@ -302,7 +303,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("Microsoft VS Code")
|
||||
.resolve("bin")
|
||||
@@ -335,7 +336,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
return Optional.of(AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Programs")
|
||||
.resolve("Microsoft VS Code Insiders")
|
||||
.resolve("bin")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.ExternalApplicationType;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
@@ -29,19 +30,12 @@ public class SecureCrtTerminalType implements ExternalApplicationType.WindowsTyp
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
try (var sc = LocalShell.getShell().start()) {
|
||||
var env = sc.executeSimpleStringCommand(
|
||||
sc.getShellDialect().getPrintEnvironmentVariableCommand("ProgramFiles"));
|
||||
var file = Path.of(env, "VanDyke Software\\SecureCRT\\SecureCRT.exe");
|
||||
if (!Files.exists(file)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.of(file);
|
||||
} catch (Exception e) {
|
||||
ErrorEventFactory.fromThrowable(e).omit().handle();
|
||||
var file = AppLocations.getWindows().getProgramFiles().resolve("VanDyke Software\\SecureCRT\\SecureCRT.exe");
|
||||
if (!Files.exists(file)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.of(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.core.AppCache;
|
||||
import io.xpipe.app.core.AppInstallation;
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.core.AppProperties;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
@@ -148,14 +149,12 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
|
||||
}
|
||||
|
||||
private Path getPath() {
|
||||
var local = System.getenv("LOCALAPPDATA");
|
||||
return Path.of(local).resolve("Microsoft\\WindowsApps\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\wt.exe");
|
||||
return AppLocations.getWindows().getLocalAppData().resolve("Microsoft\\WindowsApps\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\wt.exe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigFile() {
|
||||
var local = System.getenv("LOCALAPPDATA");
|
||||
return Path.of(local)
|
||||
return AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json");
|
||||
}
|
||||
}
|
||||
@@ -181,8 +180,7 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
|
||||
}
|
||||
|
||||
private Path getPath() {
|
||||
var local = System.getenv("LOCALAPPDATA");
|
||||
return Path.of(local)
|
||||
return AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Microsoft\\WindowsApps\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\wt.exe");
|
||||
}
|
||||
|
||||
@@ -199,8 +197,7 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
|
||||
|
||||
@Override
|
||||
public Path getConfigFile() {
|
||||
var local = System.getenv("LOCALAPPDATA");
|
||||
return Path.of(local)
|
||||
return AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json");
|
||||
}
|
||||
}
|
||||
@@ -226,8 +223,7 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
|
||||
}
|
||||
|
||||
private Path getPath() {
|
||||
var local = System.getenv("LOCALAPPDATA");
|
||||
return Path.of(local)
|
||||
return AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Microsoft\\WindowsApps\\Microsoft.WindowsTerminalCanary_8wekyb3d8bbwe\\wt.exe");
|
||||
}
|
||||
|
||||
@@ -244,8 +240,7 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
|
||||
|
||||
@Override
|
||||
public Path getConfigFile() {
|
||||
var local = System.getenv("LOCALAPPDATA");
|
||||
return Path.of(local)
|
||||
return AppLocations.getWindows().getLocalAppData()
|
||||
.resolve("Packages\\Microsoft.WindowsTerminalCanary_8wekyb3d8bbwe\\LocalState\\settings.json");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.vnc;
|
||||
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.prefs.ExternalApplicationType;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
|
||||
@@ -56,7 +57,7 @@ public abstract class RealVncClient implements ExternalVncClient {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("PROGRAMFILES"))
|
||||
return Optional.of(AppLocations.getWindows().getProgramFiles()
|
||||
.resolve("RealVNC")
|
||||
.resolve("VNC Viewer")
|
||||
.resolve("vncviewer.exe"))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.vnc;
|
||||
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.ExternalApplicationType;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
@@ -55,7 +56,7 @@ public abstract class TigerVncClient implements ExternalVncClient {
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("PROGRAMFILES"))
|
||||
return Optional.of(AppLocations.getWindows().getProgramFiles()
|
||||
.resolve("TigerVNC")
|
||||
.resolve("vncviewer.exe"))
|
||||
.filter(path -> Files.exists(path));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.vnc;
|
||||
|
||||
import io.xpipe.app.core.AppLocations;
|
||||
import io.xpipe.app.prefs.ExternalApplicationType;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
import io.xpipe.app.util.LocalShell;
|
||||
@@ -34,7 +35,7 @@ public class TightVncClient implements ExternalApplicationType.InstallLocationTy
|
||||
|
||||
@Override
|
||||
public Optional<Path> determineInstallation() {
|
||||
return Optional.of(Path.of(System.getenv("PROGRAMFILES"))
|
||||
return Optional.of(AppLocations.getWindows().getProgramFiles()
|
||||
.resolve("TightVNC")
|
||||
.resolve("tvnviewer.exe"))
|
||||
.filter(path -> Files.exists(path));
|
||||
|
||||
Reference in New Issue
Block a user