From c13075ae3cc46dd3e6dafcbf92b2a091f8e5f34f Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 16 Jul 2025 03:51:26 +0000 Subject: [PATCH] Small fixes --- .../java/io/xpipe/app/issue/ErrorEvent.java | 5 ++ .../app/prefs/WorkspaceCreationDialog.java | 62 ++++++++++--------- .../io/xpipe/app/util/DesktopShortcuts.java | 11 +++- dist/changelogs/17.0.md | 1 + 4 files changed, 48 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java b/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java index 81f5cf907..81072038d 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java @@ -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()); } diff --git a/app/src/main/java/io/xpipe/app/prefs/WorkspaceCreationDialog.java b/app/src/main/java/io/xpipe/app/prefs/WorkspaceCreationDialog.java index b6a2015d3..619a6dfb6 100644 --- a/app/src/main/java/io/xpipe/app/prefs/WorkspaceCreationDialog.java +++ b/app/src/main/java/io/xpipe/app/prefs/WorkspaceCreationDialog.java @@ -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(); } diff --git a/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java b/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java index 152f4e49f..e558b90e6 100644 --- a/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java +++ b/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java @@ -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; } diff --git a/dist/changelogs/17.0.md b/dist/changelogs/17.0.md index 433c3c9e6..7f6106909 100644 --- a/dist/changelogs/17.0.md +++ b/dist/changelogs/17.0.md @@ -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