Skip to content

System manager ​

Access through app.system (CryKit::System::Manager).

Methods ​

MethodReturnsPurposePlatform
osCryKit::System::OSIdentify Darwin, Linux, or WindowsAll
screen_infoCryKit::System::ScreenInfoRead the current main screen's dimensions and scalemacOS
accent_colorStringRead the current system accent as CSS hexmacOS
open_in_file_manager(path)NilOpen an existing directory in FindermacOS
reveal_in_file_manager(path)NilSelect a file or directory in FindermacOS

os is available before startup. Call the other native operations on the UI context after native startup, such as a mounted event callback or job.notify. Unsupported platforms raise CryKit::System::UnsupportedError.

File manager ​

crystal
app.system.open_in_file_manager("/Users/me/Documents")
app.system.reveal_in_file_manager(Path.new("/Users/me/Documents/report.pdf"))
Path ruleBehavior
TypeString or Path
Relative pathResolved against the process's working directory
Spaces, Unicode, shell metacharactersPassed literally
~ or symbolic linksNo tilde expansion or symlink resolution; target must exist
Empty, NUL-containing, invalid UTF-8, or missing pathArgumentError on macOS
Open a non-directoryArgumentError
Finder rejects the requestCryKit::System::FileManagerError

Both methods use AppKit's file viewer API. Unsupported platforms raise before path validation.

OS and screen information ​

crystal
app.system.os
screen = app.system.screen_info
ValueTypeMeaning
osCryKit::System::OSDarwin, Linux, or Windows
screen.widthInt32Full screen width in logical points
screen.heightInt32Full screen height in logical points
screen.scaleFloat64Backing pixels per logical point

ScreenInfo is immutable. Each call reads AppKit's main screen: the screen containing the window receiving keyboard events, which can differ from the primary display. Dimensions include the menu bar and Dock areas. If no main screen is available, the call raises CryKit::System::ScreenUnavailableError.

System accent color ​

crystal
accent = app.system.accent_color

Returns a lowercase six-digit sRGB CSS hex string, for example "#007aff". The getter reads the current value each time; it does not observe changes. Call again to refresh after the user's settings change.

DetailBehavior
AppearanceApplication appearance; a per-window Light/Dark override does not affect the lookup
ConversionNSColor.controlAccentColor converted to sRGB; channels rounded and clamped to bytes
Lookup or conversion failureCryKit::System::AccentColorUnavailableError

The demo application includes a system accent swatch and a refresh action.

Built with Crystal. Documented with VitePress.