primaryScreen
Signature | hs.screen.primaryScreen() -> screen |
---|---|
Type | Constructor |
Description | Gets the primary screen Parameters:
Returns:
|
Manipulate screens (i.e. monitors)
The macOS coordinate system used by Hammerspoon assumes a grid that spans all the screens (positioned as per
System Preferences->Displays->Arrangement). The origin 0,0
is at the top left corner of the primary screen.
(Screens to the left of the primary screen, or above it, and windows on these screens, will have negative coordinates)
Signature | hs.screen.strictScreenInDirection |
---|---|
Type | Variable |
Description | If set to |
Signature | hs.screen.accessibilitySettings() -> table |
---|---|
Type | Function |
Description | Gets the current state of the screen-related accessibility settings Parameters:
Returns:
|
Signature | hs.screen.find(hint) -> hs.screen object(s) |
---|---|
Type | Function |
Description | Finds screens Parameters:
Returns:
Notes:
Example: hs.screen(724562417) --> Color LCD - by id
hs.screen'Dell' --> DELL U2414M - by name
hs.screen'0,0' --> PHL BDM4065 - by position, same as hs.screen.primaryScreen()
hs.screen{x=-1,y=0} --> DELL U2414M - by position, screen to the immediate left of the primary screen
hs.screen'3840x2160' --> PHL BDM4065 - by screen resolution
hs.screen'-500,240 700x1300' --> DELL U2414M, by arbitrary rect
|
Signature | hs.screen.restoreGamma() |
---|---|
Type | Function |
Description | Restore the gamma settings to defaults Parameters:
Returns:
Notes:
|
Signature | hs.screen.screenPositions() -> table |
---|---|
Type | Function |
Description | Returns a list of all connected and enabled screens, along with their "position" relative to the primary screen Parameters:
Returns:
Notes:
|
Signature | hs.screen.allScreens() -> hs.screen[] |
---|---|
Type | Constructor |
Description | Returns all the screens Parameters:
Returns:
|
Signature | hs.screen.mainScreen() -> screen |
---|---|
Type | Constructor |
Description | Returns the 'main' screen, i.e. the one containing the currently focused window Parameters:
Returns:
|
Signature | hs.screen.primaryScreen() -> screen |
---|---|
Type | Constructor |
Description | Gets the primary screen Parameters:
Returns:
|
Signature | hs.screen:absoluteToLocal(geom) -> hs.geometry object |
---|---|
Type | Method |
Description | Transforms from the absolute coordinate space used by OSX/Hammerspoon to the screen's local
coordinate space, where Parameters:
Returns:
|
Signature | hs.screen:availableModes() -> table |
---|---|
Type | Method |
Description | Returns a table containing the screen modes supported by the screen. A screen mode is a combination of resolution, scaling factor and colour depth Parameters:
Returns:
Notes:
|
Signature | hs.screen:currentMode() -> table |
---|---|
Type | Method |
Description | Returns a table describing the current screen mode Parameters:
Returns:
|
Signature | hs.screen:desktopImageURL([imageURL]) |
---|---|
Type | Method |
Description | Gets/Sets the desktop background image for a screen Parameters:
Returns:
|
Signature | hs.screen:frame() -> hs.geometry rect |
---|---|
Type | Method |
Description | Returns the screen frame, without the dock or menu. Parameters:
Returns:
|
Signature | hs.screen:fromUnitRect(unitrect) -> hs.geometry rect |
---|---|
Type | Method |
Description | Returns the absolute rect of a given unit rect within this screen Parameters:
Returns:
Notes:
|
Signature | hs.screen:fullFrame() -> hs.geometry rect |
---|---|
Type | Method |
Description | Returns the screen frame, including the dock and menu. Parameters:
Returns:
|
Signature | hs.screen:getBrightness() -> number or nil |
---|---|
Type | Method |
Description | Gets the screen's brightness Parameters:
Returns:
|
Signature | hs.screen.getForceToGray() -> boolean |
---|---|
Type | Method |
Description | Gets the screen's ForceToGray setting Parameters:
Returns:
|
Signature | hs.screen:getGamma() -> [whitepoint, blackpoint] or nil |
---|---|
Type | Method |
Description | Gets the current whitepoint and blackpoint of the screen Parameters:
Returns:
|
Signature | hs.screen.getInvertedPolarity() -> boolean |
---|---|
Type | Method |
Description | Gets the screen's InvertedPolarity setting Parameters:
Returns:
|
Signature | hs.screen:id() -> number |
---|---|
Type | Method |
Description | Returns a screen's unique ID Parameters:
Returns:
|
Signature | hs.screen:localToAbsolute(geom) -> hs.geometry object |
---|---|
Type | Method |
Description | Transforms from the screen's local coordinate space, where Parameters:
Returns:
|
Signature | hs.screen:name() -> string or nil |
---|---|
Type | Method |
Description | Returns the preferred name for the screen set by the manufacturer Parameters:
Returns:
|
Signature | hs.screen:next() -> screen |
---|---|
Type | Method |
Description | Gets the screen 'after' this one (in arbitrary order); this method wraps around to the first screen. Parameters:
Returns:
|
Signature | hs.screen:position() -> x, y |
---|---|
Type | Method |
Description | Return a given screen's position relative to the primary screen - see 'hs.screen.screenPositions()' Parameters:
Returns:
|
Signature | hs.screen:previous() -> screen |
---|---|
Type | Method |
Description | Gets the screen 'before' this one (in arbitrary order); this method wraps around to the last screen. Parameters:
Returns:
|
Signature | hs.screen:rotate([degrees]) -> bool or rotation angle |
---|---|
Type | Method |
Description | Gets/Sets the rotation of a screen Parameters:
Returns:
|
Signature | hs.screen:setBrightness(brightness) -> |
---|---|
Type | Method |
Description | Sets the screen's brightness Parameters:
Returns:
|
Signature | hs.screen.setForceToGray(ForceToGray) -> None |
---|---|
Type | Method |
Description | Sets the screen's ForceToGray mode Parameters:
Returns:
|
Signature | hs.screen:setGamma(whitepoint, blackpoint) -> boolean |
---|---|
Type | Method |
Description | Sets the current white point and black point of the screen Parameters:
Returns:
Notes:
|
Signature | hs.screen.setInvertedPolarity(InvertedPolarity) -> None |
---|---|
Type | Method |
Description | Sets the screen's InvertedPolarity mode Parameters:
Returns:
|
Signature | hs.screen:setMode(width, height, scale) -> boolean |
---|---|
Type | Method |
Description | Sets the screen to a new mode Parameters:
Returns:
Notes:
|
Signature | hs.screen:setPrimary() -> boolean |
---|---|
Type | Method |
Description | Sets the screen to be the primary display (i.e. contain the menubar and dock) Parameters:
Returns:
|
Signature | hs.screen:shotAsJPG(filePath[, screenRect]) |
---|---|
Type | Method |
Description | Saves an image of the screen to a JPG file Parameters:
Returns:
|
Signature | hs.screen:shotAsPNG(filePath[, screenRect]) |
---|---|
Type | Method |
Description | Saves an image of the screen to a PNG file Parameters:
Returns:
|
Signature | hs.screen:snapshot([rect]) -> object |
---|---|
Type | Method |
Description | Captures an image of the screen Parameters:
Returns:
|
Signature | hs.screen:toEast() -> hs.screen object |
---|---|
Type | Method |
Description | Gets the first screen to the east of this one, ordered by proximity to its center or a specified point. Parameters:
Returns:
|
Signature | hs.screen:toNorth() -> hs.screen object |
---|---|
Type | Method |
Description | Gets the first screen to the north of this one, ordered by proximity to its center or a specified point. Parameters:
Returns:
|
Signature | hs.screen:toSouth() -> hs.screen object |
---|---|
Type | Method |
Description | Gets the first screen to the south of this one, ordered by proximity to its center or a specified point. Parameters:
Returns:
|
Signature | hs.screen:toUnitRect(rect) -> hs.geometry unitrect |
---|---|
Type | Method |
Description | Returns the unit rect of a given rect, relative to this screen Parameters:
Returns:
Notes:
|
Signature | hs.screen:toWest() -> hs.screen object |
---|---|
Type | Method |
Description | Gets the first screen to the west of this one, ordered by proximity to its center or a specified point. Parameters:
Returns:
|