Inspect and control the displays attached to the system.
Obtaining screens
const all = hs.screen.all(); // [HSScreen, ...]
const main = hs.screen.main(); // screen containing the focused window
const primary = hs.screen.primary(); // screen with the global menu bar
Navigation
const right = hs.screen.main().toEast();
if (right) console.log("Screen to the right:", right.name);
Register a listener that fires whenever the display configuration changes — monitors
connected/disconnected displays, resolution or arrangement changes, or the menu bar moving
to a different display.
Declaration
hs.screen.on(event, listener) -> None
Parameters
Name
Type
Description
event
any
The event to listen for (the only event this module emits)
listener
any
Called with no arguments when the display configuration changes; call all()/main()/primary() inside it to inspect the new configuration
Returns
None
Throws
Throws an Error on failure; wrap calls in try/catch to handle it.