Add terminate on pause option for apps (resolves #801)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -324,6 +324,14 @@
|
||||
v-model="editForm['wait-all']"
|
||||
default="true"
|
||||
></Checkbox>
|
||||
<!-- terminate on pause -->
|
||||
<Checkbox class="mb-3"
|
||||
id="terminateOnPause"
|
||||
label="apps.terminate_on_pause"
|
||||
desc="apps.terminate_on_pause_desc"
|
||||
v-model="editForm['terminate-on-pause']"
|
||||
default="false"
|
||||
></Checkbox>
|
||||
<!-- exit timeout -->
|
||||
<div class="mb-3">
|
||||
<label for="exitTimeout" class="form-label">{{ $t('apps.exit_timeout') }}</label>
|
||||
@@ -503,6 +511,7 @@
|
||||
"per-client-app-identity": false,
|
||||
"allow-client-commands": true,
|
||||
"virtual-display": false,
|
||||
"terminate-on-pause": false,
|
||||
"gamepad": ""
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"run_as_desc": "This can be necessary for some applications that require administrator permissions to run properly. Might cause URL schemes to fail.",
|
||||
"save_failed": "Failed to save app: ",
|
||||
"save_order": "Save Order",
|
||||
"terminate_on_pause": "Terminate on Pause",
|
||||
"terminate_on_pause_desc": "Terminate the app when all clients are disconnected.",
|
||||
"use_app_identity": "Use App Identity",
|
||||
"use_app_identity_desc": "Use the app's own identity while creating virtual displays instead of client's. This is useful when you want display configuration for each APP separately.",
|
||||
"virtual_display": "Always use Virtual Display",
|
||||
|
||||
@@ -106,6 +106,8 @@
|
||||
"run_as_desc": "这可能是某些需要管理员权限才能正常运行的应用程序所必需的。可能会导致 URL schemes 无法正常启动。",
|
||||
"save_failed": "保存APP失败:",
|
||||
"save_order": "保存排序",
|
||||
"terminate_on_pause": "暂停时终止",
|
||||
"terminate_on_pause_desc": "当所有客户端断开连接时终止此 APP。",
|
||||
"use_app_identity": "使用 App 身份",
|
||||
"use_app_identity_desc": "在创建虚拟显示器时使用 App 自身的身份,而非客户端的。这样可以针对 APP 进行单独的显示器组合配置。",
|
||||
"virtual_display": "总是使用虚拟显示器",
|
||||
|
||||
Reference in New Issue
Block a user