feat: native tray context menu for Linux#36
Open
fyiel wants to merge 1 commit into
Open
Conversation
- Linux trays (StatusNotifierItem/libappindicator) don't deliver click/right-click events to Electron, so the styled tray popup never opened on Linux (the icon had no menu at all) - Add a native context menu via tray.setContextMenu() on Linux: Open / Browse / Library / Downloads / Settings / Stop <game> / Quit - Rebuild the menu on game start/stop so "Stop <game>" stays accurate - Kept additive so the existing tray popup and its IPC handler are untouched - Windows/macOS unchanged (they keep the styled right-click popup)
1a7b099 to
b2389bf
Compare
Author
|
wiped first commit cause i was rewriting the tray-popup:action handler, pr is now purely additive so there shouldn't be any issues. I may also be wrong about
this was tested locally on Arch with Hyprland and waybar as the StatusNotifierItem host tested for: v0.55.4 hyprland, v0.15.0 waybar, v0.6.0 libayatana-appindicator, v0.9.5 libayatana-indicator, v3.24.52 gtk3, v33.4.11 electron |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a native system-tray context menu on Linux, so right-clicking the tray icon shows actionable buttons
Because: the tray uses tray.on('right-click'/'click') to open a custom popup, but on Linux those events are never delivered by the StatusNotifierItem/libappindicator tray, so the Linux tray icon had no menu at all. A native menu via tray.setContextMenu() is the only reliable way to make it interactive
Changes are additive and all in electron/main.cjs. There's a new buildTrayContextMenu() that builds the menu with Open, Browse, Library, Downloads, Settings, a "Stop " entry that only shows while a game is running, and Quit. createTray() attaches it with setContextMenu() on Linux only, and refreshTrayMenu() rebuilds it whenever a game starts or stops so the "Stop " line stays accurate. The existing tray popup and its IPC action handler are left untouched, and Windows and macOS keep their styled right-click popup.
Tested on Hyprland/Wayland with waybar + libayatana-appindicator3: icon shows, right-click opens the menu, actions work
No new dependencies
Contact: Discord 318912487162511370 (fywni#0)