shell: edit the command if steam runtime

Inside steam runtime we should use `steam-runtime-launch-client --alongside-steam --host`
This should resolve issues where the user tries to use commands
that don't exist inside the runtime
This commit is contained in:
flightlessmango 2024-07-01 22:35:11 +02:00
parent 159eb13341
commit c0afb84e9c
2 changed files with 9 additions and 0 deletions

View File

@ -29,6 +29,9 @@ std::string Shell::readOutput() {
}
Shell::Shell() {
if (stat("/run/pressure-vessel", &stat_buffer) == 0)
runtime = true;
static bool failed;
if (pipe(to_shell) == -1) {
SPDLOG_ERROR("Failed to create to_shell pipe: {}", strerror(errno));
@ -79,6 +82,9 @@ void Shell::writeCommand(std::string command) {
if (write(to_shell[1], command.c_str(), command.length()) == -1)
SPDLOG_ERROR("Failed to write to shell");
if (runtime)
command = "steam-runtime-launch-client --alongside-steam --host -- " + command;
trim(command);
SPDLOG_DEBUG("Shell: wrote command: {}", command);
}

View File

@ -7,6 +7,7 @@
#endif
#include <string>
#include <memory>
#include <sys/stat.h>
class Shell {
private:
@ -14,6 +15,8 @@ private:
int from_shell[2];
pid_t shell_pid;
bool success;
struct stat stat_buffer;
bool runtime = false;
#ifdef __linux__
void setNonBlocking(int fd) {