Small fixes

This commit is contained in:
crschnick
2025-07-16 03:51:26 +00:00
parent 967b28efb6
commit c13075ae3c
4 changed files with 48 additions and 31 deletions
@@ -85,6 +85,11 @@ public class ErrorEvent {
public static class ErrorEventBuilder {
public ErrorEventBuilder descriptionPrefix(String prefix) {
this.description = this.description != null ? prefix + "\n\n" + this.description : prefix;
return this;
}
public ErrorEventBuilder documentationLink(DocumentationLink documentationLink) {
return link(documentationLink.getLink());
}
@@ -34,37 +34,39 @@ public class WorkspaceCreationDialog {
.apply(struc -> AppFontSizes.xs(struc.get()));
var modal = ModalOverlay.of("workspaceCreationAlertTitle", content);
modal.addButton(ModalButton.ok(() -> {
if (name.get() == null || path.get() == null) {
return;
}
ThreadHelper.runAsync(() -> {
if (name.get() == null || path.get() == null) {
return;
}
try {
var shortcutName = (AppProperties.get().isStaging() ? "XPipe PTB" : "XPipe") + " (" + name.get() + ")";
var file =
switch (OsType.getLocal()) {
case OsType.Windows w -> {
var exec = XPipeInstallation.getCurrentInstallationBasePath()
.resolve(XPipeInstallation.getDaemonExecutablePath(w))
.toString();
yield DesktopShortcuts.create(
exec,
"-Dio.xpipe.app.dataDir=\"" + path.get().toString()
+ "\" -Dio.xpipe.app.acceptEula=true",
shortcutName);
}
default -> {
var exec = XPipeInstallation.getCurrentInstallationBasePath()
.resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.getLocal()))
.toString();
yield DesktopShortcuts.create(
exec, "-d \"" + path.get().toString() + "\" --accept-eula", shortcutName);
}
};
DesktopHelper.browseFileInDirectory(file);
OperationMode.close();
} catch (Exception e) {
ErrorEventFactory.fromThrowable(e).handle();
}
try {
var shortcutName = name.get();
var file =
switch (OsType.getLocal()) {
case OsType.Windows w -> {
var exec = XPipeInstallation.getCurrentInstallationBasePath()
.resolve(XPipeInstallation.getDaemonExecutablePath(w))
.toString();
yield DesktopShortcuts.create(
exec,
"-Dio.xpipe.app.dataDir=\"" + path.get().toString()
+ "\" -Dio.xpipe.app.acceptEula=true",
shortcutName);
}
default -> {
var exec = XPipeInstallation.getCurrentInstallationBasePath()
.resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.getLocal()))
.toString();
yield DesktopShortcuts.create(
exec, "open -d \"" + path.get().toString() + "\" --accept-eula", shortcutName);
}
};
DesktopHelper.browseFileInDirectory(file);
OperationMode.close();
} catch (Exception e) {
ErrorEventFactory.fromThrowable(e).handle();
}
});
}));
modal.show();
}
@@ -1,5 +1,6 @@
package io.xpipe.app.util;
import io.xpipe.app.process.CommandBuilder;
import io.xpipe.app.process.OsFileSystem;
import io.xpipe.core.FilePath;
import io.xpipe.core.OsType;
@@ -32,6 +33,8 @@ public class DesktopShortcuts {
}
private static Path createLinuxShortcut(String executable, String args, String name) throws Exception {
// Linux .desktop names are very restrictive
var fixedName = name.replaceAll("[^\\w _]", "");
var icon = XPipeInstallation.getLocalDefaultInstallationIcon();
var content = String.format(
"""
@@ -44,10 +47,16 @@ public class DesktopShortcuts {
Terminal=false
Categories=Utility;Development;
""",
name, executable, args, icon);
fixedName, executable, args, icon);
var file = DesktopHelper.getDesktopDirectory().resolve(name + ".desktop");
Files.writeString(file, content);
file.toFile().setExecutable(true);
// Mark shortcuts as trusted on gnome
LocalShell.getShell().command(CommandBuilder.of().add("gio", "set")
.addFile(file).addQuoted("metadata::trusted").add("yes"))
.executeAndCheck();
return file;
}
+1
View File
@@ -147,3 +147,4 @@ The HTTP API has been improved in various areas. The action system is integrated
- Fix freeze after waking up the local system from a long hibernation
- Fix application not starting up if some antivirus interfered with local socket connections
- Fix kubectl apply changes functionality for pods not working
- Fix custom workspaces not working on Linux