From 8bff4d078037b292de6f98cd2b0d0b36352306cf Mon Sep 17 00:00:00 2001 From: Kishi <41839133+Kishi85@users.noreply.github.com> Date: Mon, 1 Sep 2025 20:07:31 +0200 Subject: [PATCH] feat(tray): Add runtime config option to enable/disable system tray (#4208) --- docs/configuration.md | 23 +++++++++++++++++++ src/config.cpp | 2 ++ src/config.h | 1 + src/main.cpp | 6 ++--- src_assets/common/assets/web/config.html | 1 + .../assets/web/configs/tabs/General.vue | 8 +++++++ .../assets/web/public/assets/locale/en.json | 2 ++ 7 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 70e2a97b..2264aa8d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -261,6 +261,29 @@ editing the `conf` file in a text editor. Use the examples as reference. +### system_tray + + + + + + + + + + + + + + +
Description + Show icon in system tray and display desktop notifications +
Default@code{} + enabled + @endcode
Example@code{} + system_tray = enabled + @endcode
+ ## Input ### controller diff --git a/src/config.cpp b/src/config.cpp index e3de5735..a7b7b5cb 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -578,6 +578,7 @@ namespace config { "ipv4", // Address family platf::appdata().string() + "/sunshine.log", // log file false, // notify_pre_releases + true, // system_tray {}, // prep commands }; @@ -1229,6 +1230,7 @@ namespace config { bool_f(vars, "native_pen_touch", input.native_pen_touch); bool_f(vars, "notify_pre_releases", sunshine.notify_pre_releases); + bool_f(vars, "system_tray", sunshine.system_tray); int port = sunshine.port; int_between_f(vars, "port"s, port, {1024 + nvhttp::PORT_HTTPS, 65535 - rtsp_stream::RTSP_SETUP_PORT}); diff --git a/src/config.h b/src/config.h index cda1f7c6..7ba1bd23 100644 --- a/src/config.h +++ b/src/config.h @@ -256,6 +256,7 @@ namespace config { std::string log_file; bool notify_pre_releases; + bool system_tray; std::vector prep_cmds; }; diff --git a/src/main.cpp b/src/main.cpp index 050b2990..07cac147 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -112,7 +112,7 @@ void mainThreadLoop(const std::shared_ptr> &shutdown_event) while (true) { if (shutdown_event->peek()) { BOOST_LOG(info) << "Shutdown event detected, breaking main loop"sv; - if (tray_is_enabled) { + if (tray_is_enabled && config::sunshine.system_tray) { system_tray::end_tray(); } break; @@ -384,7 +384,7 @@ int main(int argc, char *argv[]) { } #endif - if (tray_is_enabled) { + if (tray_is_enabled && config::sunshine.system_tray) { BOOST_LOG(info) << "Starting system tray"sv; #ifdef _WIN32 // TODO: Windows has a weird bug where when running as a service and on the first Windows boot, @@ -418,7 +418,7 @@ int main(int argc, char *argv[]) { } // Stop the threaded tray if it was started - if (tray_is_enabled) { + if (tray_is_enabled && config::sunshine.system_tray) { system_tray::end_tray_threaded(); } #endif diff --git a/src_assets/common/assets/web/config.html b/src_assets/common/assets/web/config.html index 0f7c2ea5..62a37906 100644 --- a/src_assets/common/assets/web/config.html +++ b/src_assets/common/assets/web/config.html @@ -136,6 +136,7 @@ "min_log_level": 2, "global_prep_cmd": [], "notify_pre_releases": "disabled", + "system_tray": "enabled", }, }, { diff --git a/src_assets/common/assets/web/configs/tabs/General.vue b/src_assets/common/assets/web/configs/tabs/General.vue index 2e4ae109..21774d04 100644 --- a/src_assets/common/assets/web/configs/tabs/General.vue +++ b/src_assets/common/assets/web/configs/tabs/General.vue @@ -133,6 +133,14 @@ function removeCmd(index) { v-model="config.notify_pre_releases" default="false" > + + + diff --git a/src_assets/common/assets/web/public/assets/locale/en.json b/src_assets/common/assets/web/public/assets/locale/en.json index 494b5734..1a9e8fa7 100644 --- a/src_assets/common/assets/web/public/assets/locale/en.json +++ b/src_assets/common/assets/web/public/assets/locale/en.json @@ -355,6 +355,8 @@ "sw_tune_grain": "grain -- preserves the grain structure in old, grainy film material", "sw_tune_stillimage": "stillimage -- good for slideshow-like content", "sw_tune_zerolatency": "zerolatency -- good for fast encoding and low-latency streaming (default)", + "system_tray": "Enable system tray", + "system_tray_desc": "Show icon in system tray and display desktop notifications", "touchpad_as_ds4": "Emulate a DS4 gamepad if the client gamepad reports a touchpad is present", "touchpad_as_ds4_desc": "If disabled, touchpad presence will not be taken into account during gamepad type selection.", "upnp": "UPnP",