feat: add support to specifying start_dir to processes
This commit is contained in:
@@ -150,6 +150,22 @@
|
|||||||
that sleeps indefinitely
|
that sleeps indefinitely
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--starting dir-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="appStartingDir" class="form-label">Starting Dir</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control monospace"
|
||||||
|
id="appStartindDir"
|
||||||
|
aria-describedby="appStartindDirHelp"
|
||||||
|
v-model="editForm.startingDir"
|
||||||
|
/>
|
||||||
|
<div id="appStartindDirHelp" class="form-text">
|
||||||
|
The starting dir that should be passed to the process.
|
||||||
|
Some apps needs this set to find configuration files for example.
|
||||||
|
If not set, will default to the parent directory of the command
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!--buttons-->
|
<!--buttons-->
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<button @click="showEditForm = false" class="btn btn-secondary m-2">
|
<button @click="showEditForm = false" class="btn btn-secondary m-2">
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@@ -109,14 +110,17 @@ int proc_t::execute(int app_id) {
|
|||||||
if(proc.cmd.empty()) {
|
if(proc.cmd.empty()) {
|
||||||
BOOST_LOG(debug) << "Executing [Desktop]"sv;
|
BOOST_LOG(debug) << "Executing [Desktop]"sv;
|
||||||
placebo = true;
|
placebo = true;
|
||||||
}
|
} else {
|
||||||
else if(proc.output.empty() || proc.output == "null"sv) {
|
boost::filesystem::path start_dir = proc.starting_dir.empty() ?
|
||||||
BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']';
|
boost::filesystem::path(proc.cmd).parent_path() : boost::filesystem::path(proc.starting_dir);
|
||||||
_process = bp::child(_process_handle, proc.cmd, _env, bp::std_out > bp::null, bp::std_err > bp::null, ec);
|
if(proc.output.empty() || proc.output == "null"sv) {
|
||||||
}
|
BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']';
|
||||||
else {
|
_process = bp::child(_process_handle, proc.cmd, _env, bp::start_dir(start_dir), bp::std_out > bp::null, bp::std_err > bp::null, ec);
|
||||||
BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']';
|
}
|
||||||
_process = bp::child(_process_handle, proc.cmd, _env, bp::std_out > _pipe.get(), bp::std_err > _pipe.get(), ec);
|
else {
|
||||||
|
BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']';
|
||||||
|
_process = bp::child(_process_handle, proc.cmd, _env, bp::start_dir(start_dir), bp::std_out > _pipe.get(), bp::std_err > _pipe.get(), ec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ec) {
|
if(ec) {
|
||||||
@@ -275,6 +279,7 @@ std::optional<proc::proc_t> parse(const std::string &file_name) {
|
|||||||
auto output = app_node.get_optional<std::string>("output"s);
|
auto output = app_node.get_optional<std::string>("output"s);
|
||||||
auto name = parse_env_val(this_env, app_node.get<std::string>("name"s));
|
auto name = parse_env_val(this_env, app_node.get<std::string>("name"s));
|
||||||
auto cmd = app_node.get_optional<std::string>("cmd"s);
|
auto cmd = app_node.get_optional<std::string>("cmd"s);
|
||||||
|
auto starting_dir = app_node.get_optional<std::string>("startingDir"s);
|
||||||
|
|
||||||
std::vector<proc::cmd_t> prep_cmds;
|
std::vector<proc::cmd_t> prep_cmds;
|
||||||
if(prep_nodes_opt) {
|
if(prep_nodes_opt) {
|
||||||
@@ -312,6 +317,10 @@ std::optional<proc::proc_t> parse(const std::string &file_name) {
|
|||||||
ctx.cmd = parse_env_val(this_env, *cmd);
|
ctx.cmd = parse_env_val(this_env, *cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(starting_dir) {
|
||||||
|
ctx.starting_dir = parse_env_val(this_env, *starting_dir);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.name = std::move(name);
|
ctx.name = std::move(name);
|
||||||
ctx.prep_cmds = std::move(prep_cmds);
|
ctx.prep_cmds = std::move(prep_cmds);
|
||||||
ctx.detached = std::move(detached);
|
ctx.detached = std::move(detached);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ struct cmd_t {
|
|||||||
* cmd -- Runs indefinitely until:
|
* cmd -- Runs indefinitely until:
|
||||||
* No session is running and a different set of commands it to be executed
|
* No session is running and a different set of commands it to be executed
|
||||||
* Command exits
|
* Command exits
|
||||||
|
* starting_dir -- the process starting dir. This is required for some games to run properly.
|
||||||
* cmd_output --
|
* cmd_output --
|
||||||
* empty -- The output of the commands are appended to the output of sunshine
|
* empty -- The output of the commands are appended to the output of sunshine
|
||||||
* "null" -- The output of the commands are discarded
|
* "null" -- The output of the commands are discarded
|
||||||
@@ -52,6 +53,7 @@ struct ctx_t {
|
|||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string cmd;
|
std::string cmd;
|
||||||
|
std::string starting_dir;
|
||||||
std::string output;
|
std::string output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user