Expand description
One tray UI per config directory.
ui holds <config dir>/ui.lock exclusively for its whole life; the OS
releases it when the process exits, however it exits. A second ui for
the same config finds the lock taken, leaves a raise request
(ui.raise) for the running one and exits, so a config never gets two
tray icons. The running UI watches for the request and shows its window.
Structs§
- UiLock
- The held UI lock; dropping it releases the lock.
Enums§
Constants§
- LOCK_
FILE_ NAME - The UI lock’s file name, next to
config.toml. - RAISE_
FILE_ NAME - A second launch’s request to show the running UI’s window.
- RAISE_
POLL - How often the running UI looks for a raise request.
- RESTART_
ATTEMPTS - How long a UI restarting itself for the display waits for the lock its predecessor still holds: attempts × pause = 5 s.
- RESTART_
PAUSE
Functions§
- acquire
- Take the UI lock for the config at
config_path, tryingattemptstimespauseapart. A stale raise request is dropped once the lock is ours, so it cannot pop the window open later. - hand_
over - Ask the running tray UI to show its window, and say so.
- lock_
path_ for - The UI lock for the config at
config_path. - raise_
path_ for - The raise request for the config at
config_path. - take_
raise_ request - Consume a pending raise request; answers whether there was one.
- watch
- Until
stop, consume raise requests and callraisefor each, when it can (raiseanswers whether the window could be reached).