Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add systray #207

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

feat: add systray #207

wants to merge 7 commits into from

Conversation

ludoo0d0a
Copy link

What did you change?

Add systray icon.

Why did you make the change?

For better OS integration

How does this work?

createTray(mainWindow) called into mainRunner

@jooy2
Copy link
Owner

jooy2 commented Feb 7, 2025

Hello, Thank you for contributing to the project.

After testing with your code, I found the following issues. (Tested on macOS 15.3 and Node.js 22)

  • When starting for the first time with npm run dev, no window other than Tray opens. Clicking on Tray opens it. By default, a window should be displayed when the app is run.
  • The title bar in the existing code is missing in the window that opens when clicking the tray icon.
  • The window is always displayed on top. The Always on Top setting should be false by default.

Vutron is a project conceived as a template that is easy to get started with. The add-ons that can be implemented through Electron should be minimized or made optional.

There needs to be a way to disable Tray by default and enable it with a flag or constant definition.

(Also, documentation for this feature may be needed before it is merged.)

Regards,

@jooy2 jooy2 added the enhancement New feature or request label Feb 7, 2025
@ludoo0d0a
Copy link
Author

Hi, I reached a better stage.

  • tray is option for classic window (window is opened by default)
  • trayWindow is a second option (diabled by dedault) allowing to get a floating window attached to the tray (like jetbrains toolbox) (no frame, position just under tray icon)

If you're ok with evolutions, I will add documentation.

@jooy2
Copy link
Owner

jooy2 commented Feb 17, 2025

Hello, thank you for improving the code. The function is working as intended.

If you fix the remaining few bugs and improve the code, I'd be happy to merge the code!

  1. Format the code according to the project requirements. We use ESLint and Prettier. npm i -> npm run lint:fix -> npm run format:fix
  2. Remove unused comments or code. For example: import { getDisplayNearestPoint } from './desktop.ts'
  3. This may only be the case in my environment, but when I click the tray icon to toggle the tray window, the window sometimes does not open or close even if I click it intermittently. It is reproduced when I press the button at a fast interval.
  4. Can you define main/utils/Constants.ts so that options.trayOptions in MainRunner.ts and DEFAULT_OPTIONS in tray.ts do not overlap, and then use only those values?

You can skip the document creation, or submit it separately as another PR.

Regards,

@@ -0,0 +1,129 @@
import { app, screen, Menu, Tray, BaseWindow, BrowserWindow } from 'electron'
import Constants from './utils/Constants.ts'
import { getDisplayNearestPoint } from './desktop.ts'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says "ESLint: 'getDisplayNearestPoint' is defined but never used. (no-unused-vars)"


let tray;
let trayOptions;
const DEFAULT_OPTIONS = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you define main/utils/Constants.ts so that options.trayOptions in MainRunner.ts and DEFAULT_OPTIONS in tray.ts do not overlap, and then use only those values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants