Skip to main content

frontmost_application

Function frontmost_application 

Source
pub fn frontmost_application() -> Option<ForegroundApp>
Expand description

Return the currently frontmost application.

ForegroundApp::id is the identifier per-app profiles match on: the bundle identifier on macOS (e.g. "com.microsoft.VSCode"), the WM_CLASS class component under X11 / XWayland (e.g. "Code"), the xdg-shell app_id under wlroots (e.g. "org.mozilla.firefox"), and the lower-cased executable path on Windows. ForegroundApp::display_name is whatever the platform can name it, falling back to the identifier.

None when no app is frontmost, when reading fails, or on an unsupported platform — including a pure-Wayland session with no backend (see linux::detect_frontmost_source). Costs one X11 round-trip on Linux and a handful of objc_msgSends on macOS. Callers can use watch_frontmost_application_changes to drive reads from native platform events instead of polling.