From d08975a53dd1310e8d7f123faed51be8b9952f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20R=C4=99bacz?= Date: Mon, 14 Apr 2025 15:31:19 +0200 Subject: [PATCH] Fix Host::Launch to work in Flatpak sandboxed environment. (#252) --- uppsrc/ide/Core/Host.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/uppsrc/ide/Core/Host.cpp b/uppsrc/ide/Core/Host.cpp index a9583644a..33bef33c0 100644 --- a/uppsrc/ide/Core/Host.cpp +++ b/uppsrc/ide/Core/Host.cpp @@ -272,17 +272,29 @@ void Host::Launch(const char *_cmdline, bool console) if(console) cmdline = "/usr/bin/open " + script; #else - String lc = ResolveHostConsole(); - if(FileExists(lc)) - { - if(console) - cmdline = HostConsole + " sh " + script; + if(console) { + String lc = ResolveHostConsole(); + if(FileExists(lc)) + { + #ifdef FLATPAK + auto real_hc = HostConsole; + real_hc.Replace(String("/run/host/"), String("/usr/")); + cmdline = FindCommand(exedirs, CMDLINE_PREFIX + real_hc + " sh " + script); + #else + cmdline = HostConsole + " sh " + script; + #endif + } + else + if(HostConsole.GetCount()) + PutConsole("Warning: Terminal '" + lc + "' not found, executing in background."); + } +#ifdef FLATPAK + else { + cmdline = FindCommand(exedirs, CMDLINE_PREFIX + cmdline); } - else - if(HostConsole.GetCount()) - PutConsole("Warning: Terminal '" + lc + "' not found, executing in background."); #endif - +#endif + Buffer cmd_buf(strlen(cmdline) + 1); Vector args;