-
Notifications
You must be signed in to change notification settings - Fork 16
Implement system tray icon and service management #182
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
Implement system tray icon and service management #182
Conversation
This commit introduces an enhancement to the Windows UX by implementing a tray icon. This allows Kolibri to run as a background application, providing users with windows service controls and status notifications. The implementation includes: - System Tray Icon & Notifications: An icon in the taskbar displays server status with a right-click context menu for key actions (Open UI, Open Kolibri UI on logon, Run Kolibri Service on start, Exit). It uses native Windows notifications for events like "server starting" and "server ready." - Elevated Service Configuration: A `--configure-service `command allows the tray icon to modify the service start type (Automatic/Disabled) with a UAC prompt for elevation. - Background Mode: The app now supports a `--tray-only` startup flag. On Windows, closing the main window hides it to the tray instead of exiting. - Installer Integration: The Inno Setup script is updated to always install the service and adds the tray application to system startup when the service is enabled.
5e7fe9f to
7f8ee06
Compare
|
Should I change the name of taskbar_icon.py to something windows related (e.g., windows_taskbar_icon.py)? |
Changes include: - The app now checks for the WebView2 runtime at startup. If it is not found, it will open the Kolibri URL in the user's default web browser once the server is ready. - The Inno Setup script now detects legacy Windows versions and skips the WebView2 runtime installation to prevent installer errors.
|
@ozer550 noticed a scenario which I had overlooked, that results in two Kolibri server processes running simultaneously. Steps to Reproduce:
At this point, both the original local server and the newly started Windows service are running at the same time. I see two potential paths to fix this:1. Don't Start the Service Immediately
2. Handover
Thoughts? |
Option 1 appears to avoid complex race conditions, provides predictable and testable behavior, and requires only minimal code changes. |
Correctly restores the main window if it is minimized when the user: - Left-clicks the tray icon - Uses the "Open UI" menu option - Launches the app from an application shortcut
ozer550
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, Everything makes sense! Just some small changes for better code readability and future maintenance.
rtibbles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions but nothing totally blocking.
Previously, when the "Run Kolibri service on start" option was toggled on in the Windows taskbar icon menu, Kolibri would configure the service for automatic startup and attempt to start it. With this change, the "Run Kolibri service on start" option only sets the Kolibri Windows service's startup type to "Automatic". The service will then start on the next system reboot.
This commit refactors all Windows service interactions to use the `pywin32` library instead of calling `sc.exe`. The new implementation uses Windows API calls for: - Checking service status (`is_service_running`) - Getting service startup type (`get_service_start_type`) - Configuring service startup type (`_configure_service_start_type`)
Updates taskbar icon loading to use the standard `importlib.resources` library and adjusts the PyInstaller spec accordingly To support this, the `icons` directory has been moved into `src/kolibri_app` to be treated as a proper package resource. The PyInstaller spec file has been updated to reflect this new location.
|
Hi @rtibbles, I changed the location of the If you're okay with this change, could you please test that it didn't break the icons on Mac? |
The `dmgbuild_settings.py` file was still pointing to the old location of `Layout.png` and `kolibri.icns`, causing the macOS installer build to fail. This updates the paths to the new location.
91bb7e9 to
8ecd582
Compare
The previous implementation used a single fixed delay to verify if the service startup type was changed, which could lead to a race condition if the system took longer than expected to apply the change. This commit implements a polling mechanism that retries checking the service status until it is updated or a timeout is reached. This makes the UI feedback more reliable. Magic numbers for verification intervals and notification timeouts have also been replaced with named constants.
Create a new windows_registry.py module to contain all Windows Registry interactions. This refactoring moves functions for checking WebView2 installation and managing UI/tray startup settings from taskbar_icon.py and __main__.py into the new centralized module.
When the application is already running but is not the active window, launching it again from a shortcut did not bring the existing window to the foreground. This was caused by Windows' focus stealing prevention, which ignores the `view.Raise()` call from a background process. The fix temporarily sets the `wx.STAY_ON_TOP` style before raising the window, which forces it to the front, and then immediately reverts the style to restore normal behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the suggestions have been implemented, and code changes make sense to me! Nice work @Dimi20cen!
Summary
This pull request enhances the UX on Windows by introducing a system tray icon. This work builds upon the previous two-process architecture to create an improved Windows application.
Explanation of core changes (Windows):
System Tray / Taskbar Icon Integration:
KolibriTaskBarIcon) is now the primary interface for managing the application's lifecycle on Windows. It provides status notifications (starting, ready, failed) and a right-click context menu.HKEY_CURRENT_USERRun key.--configure-servicecommand.Installer and Startup Logic Overhaul:
HKEY_LOCAL_MACHINEthat launches the app in--tray-onlymode. This makes only the tray icon to appear on system start, not the full application window.Refined Window Management:
Code Pointers
--tray-onlyfor background startup and--configure-servicefor the elevated process that modifies the Windows service.KolibriTrayentry to the system-wide Run key.OnCloseevent handler is modified to hide the window on Windows instead of shutting down.References
Fixes #177
Reviewer guidance
The most critical area for review is the new Windows-specific logic, focusing on the system tray icon, and the revised installer startup behavior.
How to test on Windows:
make dependencies).make pyinstallerto build the application.dist/Kolibri-0.18.1/Kolibri-0.18.1.exeto test the standalone app.make build-installer-windows(requires Inno Setup installed)dist-installer/kolibri-setup-0.18.1.exePrimary focus for testing:
Tray Icon and Application Lifecycle
Startup Configuration (from Tray Menu)
Kolibri_UIvalue is created or deleted in the current user's Run key:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run.services.mscand a success notification appears.Single-Instance Behavior
Installer and System Startup
services.mscand verify the "Kolibri" service is installed and its "Startup Type" is "Automatic".regedit) and verify aKolibriTrayentry exists inHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.KolibriTrayregistry key does not exist in theHKLMRun key.Uninstallation Test
unins000.exe.services.msc.KolibriTrayandKolibri_UIregistry keys are removed from bothHKLMandHKCURun keys.C:\Program Files\Kolibri) is removed.C:\ProgramData\kolibriis also deleted.Testing on macOS/Linux (Regression Check):
mainbranch.Known issues:
_()and ready to be translated, but they are not translated yet.