Fix desktop shortcuts

This commit is contained in:
crschnick 2023-03-31 20:16:01 +00:00
parent 0d3274b1a4
commit 5444bc785f
2 changed files with 9 additions and 8 deletions

View file

@ -18,7 +18,7 @@ public class DesktopShortcuts {
set "SHORTCUT=%%HOMEDRIVE%%%%HOMEPATH%%\\Desktop\\%s.lnk" set "SHORTCUT=%%HOMEDRIVE%%%%HOMEPATH%%\\Desktop\\%s.lnk"
set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile
%%PWS%% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut('%%SHORTCUT%%'); $S.IconLocation='%s'; $S.TargetPath = '%%TARGET%%'; $S.Arguments = '%s'; $S.Save()" %%PWS%% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut('%%SHORTCUT%%'); $S.IconLocation='%s'; $S.WindowStyle=7; $S.TargetPath = '%%TARGET%%'; $S.Arguments = 'open %s'; $S.Save()"
""", """,
shortcutTarget, name, icon.toString(), target); shortcutTarget, name, icon.toString(), target);
LocalStore.getShell().executeSimpleCommand(content); LocalStore.getShell().executeSimpleCommand(content);
@ -51,7 +51,7 @@ public class DesktopShortcuts {
var content = String.format( var content = String.format(
""" """
#!/bin/bash #!/bin/bash
"%s" %s "%s" open %s
""", """,
exec, target); exec, target);

View file

@ -125,6 +125,8 @@ public class XPipeInstallation {
public static String getLocalInstallationBasePathForCLI(String cliExecutable) throws Exception { public static String getLocalInstallationBasePathForCLI(String cliExecutable) throws Exception {
var defaultInstallation = getLocalDefaultInstallationBasePath(true); var defaultInstallation = getLocalDefaultInstallationBasePath(true);
// Can be empty in development mode
if (cliExecutable == null) { if (cliExecutable == null) {
return defaultInstallation; return defaultInstallation;
} }
@ -133,14 +135,13 @@ public class XPipeInstallation {
return defaultInstallation; return defaultInstallation;
} }
if (FileNames.startsWith(cliExecutable, defaultInstallation)) { var path = Path.of(cliExecutable);
return defaultInstallation;
}
if (OsType.getLocal().equals(OsType.MACOS)) { if (OsType.getLocal().equals(OsType.MACOS)) {
return FileNames.getParent(FileNames.getParent(FileNames.getParent(cliExecutable))); return path.getParent().getParent().getParent().toString();
} else if (OsType.getLocal().equals(OsType.LINUX)) {
return path.getParent().getParent().getParent().toString();
} else { } else {
return FileNames.getParent(FileNames.getParent(cliExecutable)); return path.getParent().getParent().getParent().toString();
} }
} }