Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently if pystray throws any exceptions, the exception is passed through but not caught.
Without catching systray exceptions, the systray icon can be removed (i.e. by selecting Quit from the menu) without signalling to the rest of the program that it should shut down.
This happens for example if you run jellyfin-mpv-shim on a system which does not have a notifications daemon registered with dbus, pystray emits an exception when it tries to remove any lingering notifications. This fails, and jellyfin-mpv-shim is left without a systray icon, but still running in the background.
With this patch, a systray exception will gracefully terminate jellyfin-mpv-shim. It would be possible to selectively target individual exceptions which would trigger this behaviour, however looking at the other times where exceptions are caught in the codebase the
try/except/pass
patterns seems fairly widely used, so I went with that.