This commit is contained in:
crschnick
2025-01-28 15:09:09 +00:00
parent de75a18a81
commit 446ce5b1c8
6 changed files with 37 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.resources.AppImages;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.core.util.ValidationException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -23,6 +24,13 @@ public class SystemIconManager {
all.add(SystemIconSource.Directory.builder().path(DataStorage.get().getIconsDir()).id("custom").build());
all.add(SystemIconSource.GitRepository.builder().remote("https://github.com/selfhst/icons").id("selfhst").build());
for (var pref : prefs) {
try {
pref.checkComplete();
} catch (ValidationException e) {
ErrorEvent.fromThrowable(e).omit().expected().handle();
continue;
}
if (!all.contains(pref)) {
all.add(pref);
}

View File

@@ -6,8 +6,10 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.Validators;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.util.ValidationException;
import lombok.Builder;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
@@ -32,6 +34,12 @@ public interface SystemIconSource {
Path path;
String id;
@Override
public void checkComplete() throws ValidationException {
Validators.nonNull(path);
Validators.notEmpty(id);
}
@Override
public void refresh() throws Exception {
Files.createDirectories(path);
@@ -73,6 +81,12 @@ public interface SystemIconSource {
String remote;
String id;
@Override
public void checkComplete() throws ValidationException {
Validators.notEmpty(remote);
Validators.notEmpty(id);
}
@Override
public void refresh() throws Exception {
try (var sc = ProcessControlProvider.get().createLocalProcessControl(true).start()) {
@@ -111,6 +125,8 @@ public interface SystemIconSource {
}
}
void checkComplete() throws ValidationException;
void refresh() throws Exception;
String getId();

View File

@@ -81,6 +81,11 @@ public class IconsCategory extends AppPrefsCategory {
return;
}
// Don't use the git sync repo itself ...
if (remote.get().equals(AppPrefs.get().storageGitRemote().get())) {
return;
}
var source = SystemIconSource.GitRepository.builder().remote(remote.get()).id(UUID.randomUUID().toString()).build();
if (!sources.contains(source)) {
sources.add(source);

View File

@@ -60,7 +60,7 @@ public class TroubleshootCategory extends AppPrefsCategory {
.toString(),
XPipeInstallation.getDaemonDebugScriptPath(OsType.getLocal()));
// We can't use the SSH bridge
var type = ExternalTerminalType.determineNonSshBridgeFallback(
var type = ExternalTerminalType.determineFallbackTerminalToOpen(
AppPrefs.get().terminalType().getValue());
TerminalLauncher.openDirect(
"XPipe Debug",

View File

@@ -57,21 +57,21 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
// }
// };
static ExternalTerminalType determineNonSshBridgeFallback(ExternalTerminalType type) {
static ExternalTerminalType determineFallbackTerminalToOpen(ExternalTerminalType type) {
if (type == XSHELL || type == MOBAXTERM || type == SECURECRT) {
return ProcessControlProvider.get().getEffectiveLocalDialect() == ShellDialects.CMD ? CMD : POWERSHELL;
}
if (type != TERMIUS) {
if (type != TERMIUS && type instanceof WaveTerminalType) {
return type;
}
switch (OsType.getLocal()) {
case OsType.Linux linux -> {
// This should not be termius as all others take precedence
// This should not be termius or wave as all others take precedence
var def = determineDefault(null);
// If there's no other terminal available, use a fallback which won't work
return def != TERMIUS ? def : XTERM;
return def != TERMIUS && def != WaveTerminalType.WAVE_LINUX ? def : XTERM;
}
case OsType.MacOs macOs -> {
return MACOS_TERMINAL;

View File

@@ -181,7 +181,7 @@ public class AppInstaller {
runAndClose(() -> {
// We can't use the SSH bridge
var type = ExternalTerminalType.determineNonSshBridgeFallback(
var type = ExternalTerminalType.determineFallbackTerminalToOpen(
AppPrefs.get().terminalType().getValue());
TerminalLauncher.openDirect("XPipe Updater", sc -> command, type);
});
@@ -222,7 +222,7 @@ public class AppInstaller {
runAndClose(() -> {
// We can't use the SSH bridge
var type = ExternalTerminalType.determineNonSshBridgeFallback(
var type = ExternalTerminalType.determineFallbackTerminalToOpen(
AppPrefs.get().terminalType().getValue());
TerminalLauncher.openDirect("XPipe Updater", sc -> command, type);
});
@@ -263,7 +263,7 @@ public class AppInstaller {
runAndClose(() -> {
// We can't use the SSH bridge
var type = ExternalTerminalType.determineNonSshBridgeFallback(
var type = ExternalTerminalType.determineFallbackTerminalToOpen(
AppPrefs.get().terminalType().getValue());
TerminalLauncher.openDirect("XPipe Updater", sc -> command, type);
});