diff --git a/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs b/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs index 39bf590fb..0de793d7d 100644 --- a/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs +++ b/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs @@ -44,42 +44,58 @@ namespace System.Application.Services.Implementation stream.Flush(); stream.Close(); } - using var p = new Process(); - p.StartInfo.FileName = "/bin/bash"; - p.StartInfo.Arguments = $"\"{file.FullName}\""; - p.StartInfo.UseShellExecute = false; - p.StartInfo.RedirectStandardOutput = true; - p.Exited += (object? _, EventArgs _) => + using (var p = new Process()) { + p.StartInfo.FileName = "/bin/bash"; + p.StartInfo.Arguments = $"\"{file.FullName}\""; + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.Exited += (object? _, EventArgs _) => + { + if (file.Exists) + file.Delete(); + if (p.ExitCode != 0) + { + ((IPlatformService)this).AdminShell(shell); + } + }; + p.Start(); + var ret = p.StandardOutput.ReadToEnd(); + p.Kill(); if (file.Exists) file.Delete(); - if (p.ExitCode != 0) - { - ((IPlatformService)this).AdminShell(shell); - } - }; - p.Start(); - var ret = p.StandardOutput.ReadToEnd(); - p.Kill(); - if (file.Exists) - file.Delete(); + } } public string GetCommandLineArgs(Process process) { return string.Empty; } + public const string xdg = "xdg-open"; public void OpenFolder(string dirPath) { + if (IOPath.IsDirectory(dirPath)) + { + IDesktopPlatformService.Instance.StartProcess(xdg, dirPath); + } + else + { + var path = new FileInfo(dirPath); + if (!string.IsNullOrWhiteSpace(path.DirectoryName)) + IDesktopPlatformService.Instance.StartProcess(xdg, path.DirectoryName); + } } public const string kate = "kate"; public const string vi = "vi"; + const string VSC = "code"; - public string? GetFileName(TextReaderProvider provider) + public string? GetFileName(TextReaderProvider provider) => provider switch { - return vi; - } + TextReaderProvider.VSCode => VSC, + TextReaderProvider.Notepad => kate, + _ => null, + }; public void SetSystemSessionEnding(Action action) { diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs index 96dc9826d..31dbac3fc 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs @@ -7,6 +7,7 @@ using System.Application.Services; using System.Application.UI.Resx; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Properties; using System.Reactive; @@ -56,7 +57,7 @@ namespace System.Application.UI.ViewModels //}); OpenCertificateDirCommand = ReactiveCommand.Create(() => { - DI.Get().OpenFolder(IOPath.AppDataDirectory + @$"\{ThisAssembly.AssemblyProduct}.Certificate.cer"); + DI.Get().OpenFolder(Path.Combine(IOPath.AppDataDirectory, $"{ThisAssembly.AssemblyProduct}.Certificate.cer")); }); ProxySettingsCommand = ReactiveCommand.Create(() => {