fix: rename starting dir with working dir

This commit is contained in:
Felipe Cavalcanti 2021-08-24 21:13:33 -03:00
parent f38bbf90bb
commit 4a750c7b16
3 changed files with 18 additions and 18 deletions

View File

@ -150,20 +150,20 @@
that sleeps indefinitely
</div>
</div>
<!--starting dir-->
<!--working dir-->
<div class="mb-3">
<label for="appStartingDir" class="form-label">Starting Dir</label>
<label for="appWorkingDir" class="form-label">Working Directory</label>
<input
type="text"
class="form-control monospace"
id="appStartindDir"
aria-describedby="appStartindDirHelp"
v-model="editForm.startingDir"
id="appWorkingDir"
aria-describedby="appWorkingDirHelp"
v-model="editForm['working-dir']"
/>
<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 id="appWorkingDirHelp" class="form-text">
The working directory that should be passed to the process.
For example, some applications use the working directory to search for configuration files.
If not set, Sunshine will default to the parent directory of the command
</div>
</div>
<!--buttons-->

View File

@ -111,15 +111,15 @@ int proc_t::execute(int app_id) {
BOOST_LOG(debug) << "Executing [Desktop]"sv;
placebo = true;
} else {
boost::filesystem::path start_dir = proc.starting_dir.empty() ?
boost::filesystem::path(proc.cmd).parent_path() : boost::filesystem::path(proc.starting_dir);
boost::filesystem::path working_dir = proc.working_dir.empty() ?
boost::filesystem::path(proc.cmd).parent_path() : boost::filesystem::path(proc.working_dir);
if(proc.output.empty() || proc.output == "null"sv) {
BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']';
_process = bp::child(_process_handle, proc.cmd, _env, bp::start_dir(start_dir), bp::std_out > bp::null, bp::std_err > bp::null, ec);
_process = bp::child(_process_handle, proc.cmd, _env, bp::start_dir(working_dir), bp::std_out > bp::null, bp::std_err > bp::null, 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);
_process = bp::child(_process_handle, proc.cmd, _env, bp::start_dir(working_dir), bp::std_out > _pipe.get(), bp::std_err > _pipe.get(), ec);
}
}
@ -279,7 +279,7 @@ std::optional<proc::proc_t> parse(const std::string &file_name) {
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 cmd = app_node.get_optional<std::string>("cmd"s);
auto starting_dir = app_node.get_optional<std::string>("startingDir"s);
auto working_dir = app_node.get_optional<std::string>("working-dir"s);
std::vector<proc::cmd_t> prep_cmds;
if(prep_nodes_opt) {
@ -317,8 +317,8 @@ std::optional<proc::proc_t> parse(const std::string &file_name) {
ctx.cmd = parse_env_val(this_env, *cmd);
}
if(starting_dir) {
ctx.starting_dir = parse_env_val(this_env, *starting_dir);
if(working_dir) {
ctx.working_dir = parse_env_val(this_env, *working_dir);
}
ctx.name = std::move(name);

View File

@ -34,7 +34,7 @@ struct cmd_t {
* cmd -- Runs indefinitely until:
* No session is running and a different set of commands it to be executed
* Command exits
* starting_dir -- the process starting dir. This is required for some games to run properly.
* working_dir -- the process working directory. This is required for some games to run properly.
* cmd_output --
* empty -- The output of the commands are appended to the output of sunshine
* "null" -- The output of the commands are discarded
@ -53,7 +53,7 @@ struct ctx_t {
std::string name;
std::string cmd;
std::string starting_dir;
std::string working_dir;
std::string output;
};