Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add an option to accept or discard command output #1993

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
4 changes: 4 additions & 0 deletions metadata/workarounds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<option name="enable_so_unloading" type="bool">
<_short>Enable calling dlclose() when a plugin is unloaded. Note that this may not work well with all plugins.</_short>
<default>false</default>
</option>
<option name="discard_command_output" type="bool">
<_short>Discard output from commands invoked by Wayfire, so that they don't end up in the logs.</_short>
<default>true</default>
</option>
</plugin>
</wayfire>
3 changes: 3 additions & 0 deletions src/core/core-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class compositor_core_impl_t : public compositor_core_t
compositor_state_t state = compositor_state_t::UNKNOWN;
compositor_core_impl_t();
virtual ~compositor_core_impl_t();

private:
wf::option_wrapper_t<bool> discard_command_output;
};

compositor_core_impl_t& get_core_impl();
Expand Down
13 changes: 9 additions & 4 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ void wf::compositor_core_impl_t::post_init()
// Start processing cursor events
seat->priv->cursor->setup_listeners();

discard_command_output.load_option("workarounds/discard_command_output");

core_startup_finished_signal startup_ev;
this->emit(&startup_ev);
}
Expand Down Expand Up @@ -391,10 +393,13 @@ pid_t wf::compositor_core_impl_t::run(std::string command)
}

#endif
int dev_null = open("/dev/null", O_WRONLY);
dup2(dev_null, 1);
dup2(dev_null, 2);
close(dev_null);
if (discard_command_output)
{
int dev_null = open("/dev/null", O_WRONLY);
dup2(dev_null, 1);
dup2(dev_null, 2);
close(dev_null);
}

_exit(execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL));
} else
Expand Down