Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions src/Native/Linux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ public string FindTerminal(Models.ShellOrTerminal shell)
return test;
}

return string.Empty;
if (IsFlatpak())
{
return shell.Exec;
}
else
{
return string.Empty;
}
}

public List<Models.ExternalTool> FindExternalTools()
Expand Down Expand Up @@ -71,16 +78,33 @@ public void OpenInFileManager(string path, bool select)

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();
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? "~" : workdir;
startInfo.FileName = OS.ShellOrTerminal;
Process.Start(startInfo);
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? home : workdir;
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)
Expand Down Expand Up @@ -116,5 +140,11 @@ private string FindJetBrainsFleet()
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";
}
}
}
2 changes: 1 addition & 1 deletion src/Native/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void OpenBrowser(string url)
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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Native/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void OpenTerminal(string workdir)
{
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;
}

Expand Down