Repository navigation
System tray: minimise/close to tray, start minimised, launch at startup - #11
Merged
Merged
Conversation
…tartup Closes #10. - Tray icon (tray-icon crate): left click shows the window, right click opens Show / Exit. - Settings menu with Minimise to tray, Close to tray, Start minimised (saved to %APPDATA%\Throttle\settings.json, all off by default) and Launch at startup. - Launch at startup registers a Task Scheduler logon task with highest privileges, no time limit, normal priority and no battery conditions, started with --tray. The Run key cannot start an elevated app. - Snapshot draining and tray handling move to App::logic, which keeps running while the window is hidden, so the unbounded snapshot channel does not grow in the background. - A second launch signals the running instance through a named event to show itself, instead of calling ShowWindow from outside, which would desync winit's cached visibility. - File > Exit, tray Exit and the update relaunch always quit, even with Close to tray on.
Right after a restore the window still reads as minimised for a frame, so the minimise check hid it again. Hide only when the window becomes minimised.
…nd launch - Starting in the tray waits for the taskbar before hiding: tray-icon reports success even when the taskbar does not exist yet, so hiding on the first frame at logon could leave no icon to click. Gives up and stays visible after a minute. - The startup check only re-points the task when the exe it starts no longer exists, so running another copy once no longer takes it over. Each task XML write uses its own temp file. - The show event is created with the single-instance lock, so a second launch during startup is queued instead of lost. The error window is raised by a second launch too. - A relaunch after an in-app update always shows the window, even with Start minimised on.
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.
Closes #10.
What's new
Tray icon. Left click shows the window; right click opens Show Throttle / Exit.
Settings menu (new) with:
The first three are saved to
%APPDATA%\Throttle\settings.jsonand are all off by default, so nothing changes for existing users until they opt in.Double-clicking
throttle.exewhile it's hidden brings the existing window back.How it works
Runregistry key: Windows silently skipsRunentries for apps that require elevation. The task runs with highest privileges and is started with--tray. It overrides three Task Scheduler defaults that would hurt a background shaper: the 72-hour execution limit (now none), the battery conditions (now off) and below-normal priority (now normal). The task's existence is the source of truth for the setting.App::logic. eframe 0.36 stops callingui()while the window is hidden, but keeps callinglogic(). Snapshot draining, tray events and close handling now live there. Without this the unbounded snapshot channel would have grown by about one snapshot a second while Throttle sat in the tray.Global\ThrottleShowRequest) to show itself, instead of callingShowWindowfrom outside. winit caches window visibility, so an outsideShowWindowwould leave it unable to hide the window again.tray-icon0.26.1 (no default features).Testing
cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test(29 passing, 4 new for settings and the task XML) andcargo build --releaseall pass.schtasksto confirm the settings are accepted, then deleted.Also bumps the version to 0.1.3.
Review follow-up (a2a4541)
tray-iconreports success even when the taskbar doesn't exist yet, so at logon the window could hide with no icon to click. If the taskbar hasn't appeared after a minute, Throttle stays visible.USERDOMAIN/USERNAME. Under over-the-shoulder UAC elevation that names the admin account rather than the signed-in user. Using the token's SID would fix it; left for a follow-up.