Skip to content

Commit 0dc80cf

Browse files
committed
fix(Core): use open utility on macOS
1 parent 762f9a5 commit 0dc80cf

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

SnapX.Core/Utils/URLHelpers.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,39 @@ public static class URLHelpers
3838
public static void OpenURL(string? url)
3939
{
4040
if (string.IsNullOrEmpty(url)) return;
41+
4142
Task.Run(() =>
4243
{
4344
try
4445
{
45-
using var process = new Process();
4646
var psi = new ProcessStartInfo
4747
{
48-
UseShellExecute = true,
48+
UseShellExecute = true
4949
};
50+
5051
if (!string.IsNullOrEmpty(HelpersOptions.BrowserPath))
5152
{
5253
psi.FileName = HelpersOptions.BrowserPath;
5354
psi.Arguments = url;
5455
}
56+
else if (OperatingSystem.IsMacOS())
57+
{
58+
psi.FileName = "open";
59+
psi.Arguments = url;
60+
psi.UseShellExecute = false;
61+
}
62+
// else if (OperatingSystem.IsLinux() || OperatingSystem.IsFreeBSD())
63+
// {
64+
// psi.FileName = "xdg-open";
65+
// psi.Arguments = url;
66+
// psi.UseShellExecute = false;
67+
// }
5568
else
5669
{
5770
psi.FileName = url;
5871
}
5972

60-
process.StartInfo = psi;
61-
process.Start();
62-
73+
using var process = Process.Start(psi);
6374
DebugHelper.WriteLine("URL opened: " + url);
6475
}
6576
catch (Exception e)

0 commit comments

Comments
 (0)