Skip to content

Commit 8bff4d0

Browse files
authored
feat(tray): Add runtime config option to enable/disable system tray (#4208)
1 parent 73f84fb commit 8bff4d0

File tree

7 files changed

+40
-3
lines changed

7 files changed

+40
-3
lines changed

docs/configuration.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,29 @@ editing the `conf` file in a text editor. Use the examples as reference.
261261
</tr>
262262
</table>
263263

264+
### system_tray
265+
266+
<table>
267+
<tr>
268+
<td>Description</td>
269+
<td colspan="2">
270+
Show icon in system tray and display desktop notifications
271+
</td>
272+
</tr>
273+
<tr>
274+
<td>Default</td>
275+
<td colspan="2">@code{}
276+
enabled
277+
@endcode</td>
278+
</tr>
279+
<tr>
280+
<td>Example</td>
281+
<td colspan="2">@code{}
282+
system_tray = enabled
283+
@endcode</td>
284+
</tr>
285+
</table>
286+
264287
## Input
265288

266289
### controller

src/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ namespace config {
578578
"ipv4", // Address family
579579
platf::appdata().string() + "/sunshine.log", // log file
580580
false, // notify_pre_releases
581+
true, // system_tray
581582
{}, // prep commands
582583
};
583584

@@ -1229,6 +1230,7 @@ namespace config {
12291230
bool_f(vars, "native_pen_touch", input.native_pen_touch);
12301231

12311232
bool_f(vars, "notify_pre_releases", sunshine.notify_pre_releases);
1233+
bool_f(vars, "system_tray", sunshine.system_tray);
12321234

12331235
int port = sunshine.port;
12341236
int_between_f(vars, "port"s, port, {1024 + nvhttp::PORT_HTTPS, 65535 - rtsp_stream::RTSP_SETUP_PORT});

src/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ namespace config {
256256

257257
std::string log_file;
258258
bool notify_pre_releases;
259+
bool system_tray;
259260
std::vector<prep_cmd_t> prep_cmds;
260261
};
261262

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void mainThreadLoop(const std::shared_ptr<safe::event_t<bool>> &shutdown_event)
112112
while (true) {
113113
if (shutdown_event->peek()) {
114114
BOOST_LOG(info) << "Shutdown event detected, breaking main loop"sv;
115-
if (tray_is_enabled) {
115+
if (tray_is_enabled && config::sunshine.system_tray) {
116116
system_tray::end_tray();
117117
}
118118
break;
@@ -384,7 +384,7 @@ int main(int argc, char *argv[]) {
384384
}
385385
#endif
386386

387-
if (tray_is_enabled) {
387+
if (tray_is_enabled && config::sunshine.system_tray) {
388388
BOOST_LOG(info) << "Starting system tray"sv;
389389
#ifdef _WIN32
390390
// 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[]) {
418418
}
419419

420420
// Stop the threaded tray if it was started
421-
if (tray_is_enabled) {
421+
if (tray_is_enabled && config::sunshine.system_tray) {
422422
system_tray::end_tray_threaded();
423423
}
424424
#endif

src_assets/common/assets/web/config.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ <h1 class="my-4">{{ $t('config.configuration') }}</h1>
136136
"min_log_level": 2,
137137
"global_prep_cmd": [],
138138
"notify_pre_releases": "disabled",
139+
"system_tray": "enabled",
139140
},
140141
},
141142
{

src_assets/common/assets/web/configs/tabs/General.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ function removeCmd(index) {
133133
v-model="config.notify_pre_releases"
134134
default="false"
135135
></Checkbox>
136+
137+
<!-- Enable system tray -->
138+
<Checkbox class="mb-3"
139+
id="system_tray"
140+
locale-prefix="config"
141+
v-model="config.system_tray"
142+
default="true"
143+
></Checkbox>
136144
</div>
137145
</template>
138146

src_assets/common/assets/web/public/assets/locale/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@
355355
"sw_tune_grain": "grain -- preserves the grain structure in old, grainy film material",
356356
"sw_tune_stillimage": "stillimage -- good for slideshow-like content",
357357
"sw_tune_zerolatency": "zerolatency -- good for fast encoding and low-latency streaming (default)",
358+
"system_tray": "Enable system tray",
359+
"system_tray_desc": "Show icon in system tray and display desktop notifications",
358360
"touchpad_as_ds4": "Emulate a DS4 gamepad if the client gamepad reports a touchpad is present",
359361
"touchpad_as_ds4_desc": "If disabled, touchpad presence will not be taken into account during gamepad type selection.",
360362
"upnp": "UPnP",

0 commit comments

Comments
 (0)