diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs index 30aa7cc9..aa24b179 100644 --- a/src/Native/Linux.cs +++ b/src/Native/Linux.cs @@ -35,7 +35,14 @@ namespace SourceGit.Native return test; } - return string.Empty; + if (IsFlatpak()) + { + return shell.Exec; + } + else + { + return string.Empty; + } } public List FindExternalTools() @@ -71,17 +78,33 @@ namespace SourceGit.Native public void OpenTerminal(string workdir) { - if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal)) + if (string.IsNullOrEmpty(OS.ShellOrTerminal)) { - App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured."); + App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured."); return; } var startInfo = new ProcessStartInfo(); var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? home : workdir; - startInfo.FileName = OS.ShellOrTerminal; - Process.Start(startInfo); + if (IsFlatpak()) + { + startInfo.FileName = "flatpak-spawn"; + startInfo.ArgumentList.Add("--host"); + startInfo.ArgumentList.Add(OS.ShellOrTerminal); + } + else + { + startInfo.FileName = OS.ShellOrTerminal; + } + try + { + Process.Start(startInfo); + } + catch (Exception e) + { + App.RaiseException(workdir, e.Message); + } } public void OpenWithDefaultEditor(string file) @@ -117,5 +140,11 @@ namespace SourceGit.Native var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox/apps/fleet/bin/Fleet"; return File.Exists(path) ? path : FindExecutable("fleet"); } + + private static bool IsFlatpak() + { + var container = Environment.GetEnvironmentVariable("container"); + return container == "flatpak"; + } } } diff --git a/src/Native/OS.cs b/src/Native/OS.cs index 87655798..7df0b3ae 100644 --- a/src/Native/OS.cs +++ b/src/Native/OS.cs @@ -95,7 +95,7 @@ namespace SourceGit.Native public static void OpenTerminal(string workdir) { if (string.IsNullOrEmpty(ShellOrTerminal)) - App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured."); + App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured."); else _backend.OpenTerminal(workdir); } diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index 19362d0c..13438e02 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -160,7 +160,7 @@ namespace SourceGit.Native { if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal)) { - App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured."); + App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured."); return; }