Add terminate on pause option for apps (resolves #801)

This commit is contained in:
Yukino Song
2025-06-04 19:02:10 +08:00
parent e52176707f
commit d316b272da
6 changed files with 31 additions and 3 deletions

View File

@@ -593,6 +593,16 @@ namespace proc {
return 0;
}
void proc_t::pause() {
if (_app.terminate_on_pause) {
terminate();
} else {
#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1
system_tray::update_tray_pausing(proc::proc.get_last_run_app_name());
#endif
}
}
void proc_t::terminate(bool immediate, bool needs_refresh) {
std::error_code ec;
placebo = false;
@@ -1219,6 +1229,7 @@ namespace proc {
ctx.use_app_identity = app_node.value("use-app-identity", false);
ctx.per_client_app_identity = app_node.value("per-client-app-identity", false);
ctx.allow_client_commands = app_node.value("allow-client-commands", true);
ctx.terminate_on_pause = app_node.value("terminate-on-pause", false);
ctx.gamepad = app_node.value("gamepad", "");
// Calculate a unique application id.
@@ -1284,6 +1295,7 @@ namespace proc {
ctx.use_app_identity = false;
ctx.per_client_app_identity = false;
ctx.allow_client_commands = false;
ctx.terminate_on_pause = false;
ctx.elevated = false;
ctx.auto_detach = true;
@@ -1317,6 +1329,7 @@ namespace proc {
ctx.use_app_identity = false;
ctx.per_client_app_identity = false;
ctx.allow_client_commands = false;
ctx.terminate_on_pause = false;
ctx.elevated = false;
ctx.auto_detach = true;
@@ -1351,6 +1364,7 @@ namespace proc {
ctx.use_app_identity = false;
ctx.per_client_app_identity = false;
ctx.allow_client_commands = false;
ctx.terminate_on_pause = false;
ctx.elevated = false;
ctx.auto_detach = true;
@@ -1386,6 +1400,7 @@ namespace proc {
ctx.use_app_identity = false;
ctx.per_client_app_identity = false;
ctx.allow_client_commands = false;
ctx.terminate_on_pause = false;
ctx.elevated = false;
ctx.auto_detach = true;

View File

@@ -94,6 +94,7 @@ namespace proc {
bool use_app_identity;
bool per_client_app_identity;
bool allow_client_commands;
bool terminate_on_pause;
int scale_factor;
std::chrono::seconds exit_timeout;
};
@@ -135,6 +136,7 @@ namespace proc {
std::string get_last_run_app_name();
std::string get_running_app_uuid();
boost::process::v1::environment get_env();
void pause();
void terminate(bool immediate = false, bool needs_refresh = true);
private:

View File

@@ -2070,9 +2070,7 @@ namespace stream {
if (--running_sessions == 0) {
bool revert_display_config {config::video.dd.config_revert_on_disconnect};
if (proc::proc.running()) {
#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1
system_tray::update_tray_pausing(proc::proc.get_last_run_app_name());
#endif
proc::proc.pause();
} else {
// We have no app running and also no clients anymore.
revert_display_config = true;