fix: workaround for broken or missing tray icon menu on linux #1287
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.
When submitting this pull request, I confirm the following (please check the boxes):
Fill in the PR content:
Hydra's tray icon has been broken for quite some time on Linux. When right clicking, either a blank menu is displayed, or nothing at all. I have experienced this issue on various desktop environments such as Cinnamon, Gnome, and XFCE. This is probably more of an issue with Electron itself.
This is a workaround that is meant to set the context menu on initial app load, so that Linux users will at least be able to do something with the tray icon. For example, they can now safely "Quit" the app from the tray menu if they have the "Don't hide Hydra when closing" behavior option unchecked. Without this workaround, Linux users either have to keep that option checked to remove the "hide" feature or kill the app from the CLI or their "process manager" if they left it unchecked.
Explaining why this is likely an Electron issue:
According to the Electron docs - https://www.electronjs.org/docs/latest/api/tray
The
right-click
instance event is only supported on macOS and Windows. This event listener is being set in Hydra along with the regularclick
event, but it does absolutely nothing on Linux. The event never gets registered, thereforeshowContextMenu
never runs.The
popUpContextMenu
method is only supported on macOS and Windows. This is what Hydra is using in theshowContextMenu
function. It does absolutely nothing on Linux.