Expand description
System preferences the UI follows (light / dark, accent colour, reduced motion, more contrast) and hand-offs to the OS (open a URL in the browser, open a file in its default app, reveal a file in the file manager).
Preferences are read on demand and cheap enough for a settings change or window focus, not for every frame: cache them and re-read when the window gains focus.
Structs§
- Preferences
- What the user chose in the OS.
None= unknown here.
Enums§
Constants§
- MAX_
LANGUAGES - The most languages
preferred_languagesreturns. - OPEN_
URL_ SCHEMES - URL schemes
open_urlhands to the OS. Anything else (file:,javascript:, custom app schemes) could start arbitrary programs, so it is refused.
Functions§
- bring_
to_ front - Bring the app and
windowto the front and give it the keyboard focus, restoring it if it is minimized. For “the second launch hands over to the first” and tray / global-shortcut activations, where the windowing library’s focus request alone may be refused. - check_
url - Check a URL for
open_url: an allowed scheme, one line, bounded. - open_
path - Open a file or folder in its default app.
- open_
url - Open a web or mail link in the user’s default app.
- preferences
- The OS preferences now.
- preferred_
languages - The user’s preferred UI languages, most preferred first, as BCP 47 tags (
en-GB,de,zh-Hans-CN): macOSNSLocale.preferredLanguages, WindowsGetUserPreferredUILanguages; empty elsewhere (Linux hasLANG/LANGUAGE) and when unknown. Desktop launches often have noLANG, so apps read this as well. At mostMAX_LANGUAGEStags of at most 64 bytes. - reveal
- Show a file selected in Finder / Explorer / the file manager.