{"id":15675700,"url":"https://github.com/codebytere/node-mac-displays","last_synced_at":"2025-05-07T00:23:42.451Z","repository":{"id":46497358,"uuid":"318592291","full_name":"codebytere/node-mac-displays","owner":"codebytere","description":"A native Node.js module for enumerating over macOS system display information","archived":false,"fork":false,"pushed_at":"2021-11-11T18:12:06.000Z","size":129,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-28T19:02:36.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codebytere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-04T17:43:40.000Z","updated_at":"2025-02-19T14:05:39.000Z","dependencies_parsed_at":"2022-08-26T23:40:40.094Z","dependency_job_id":null,"html_url":"https://github.com/codebytere/node-mac-displays","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-displays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-displays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-displays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-displays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebytere","download_url":"https://codeload.github.com/codebytere/node-mac-displays/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252789359,"owners_count":21804426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T16:00:37.016Z","updated_at":"2025-05-07T00:23:42.429Z","avatar_url":"https://github.com/codebytere.png","language":"JavaScript","readme":"# node-mac-displays\n\nThis native Node.js module allows you to enumerate over system display information.\n\n## API\n\n### `Display` Object\n\nThe `Display` object represents a physical display connected to the system. A\nfake `Display` may exist on a headless system, or a `Display` may correspond to\na remote, virtual display.\n\nDisplay objects take the following format:\n\n* `id` Number - The display's unique identifier.\n* `name` String - The human-readable name of the display.\n* `supportedWindowDepths` Number[] - The window depths supported by the display.\n* `rotation` Number - The screen rotation in clockwise degrees.\n* `scaleFactor` Number - Output device's pixel scale factor.\n* `isMonochrome` Boolean - Whether or not the display is a monochrome display.\n* `colorSpace` Object - Representation of a custom color space.\n  * `name` String - The localized name of the color space.\n  * `componentCount` Number - The number of components, excluding alpha, the color space supports.\n* `depth` Number - The number of bits per pixel.\n* `bounds` Object\n  * `x` Number - The x coordinate of the origin of the rectangle.\n  * `y` Number - The y coordinate of the origin of the rectangle.\n  * `width` Number - The width of the rectangle.\n  * `height` Number - The height of the rectangle.\n* `workArea` Object\n  * `x` Number - The x coordinate of the origin of the rectangle.\n  * `y` Number - The y coordinate of the origin of the rectangle.\n  * `width` Number - The width of the rectangle.\n  * `height` Number - The height of the rectangle.\n* `internal` Boolean - `true` for an internal display and `false` for an external display.\n* `isAsleep` Boolean -  Whether or not the display is sleeping.\n* `refreshRate` Number - Returns the refresh rate of the specified display.\n\n### `displays.getAllDisplays()`\n\nReturns `Array\u003cObject\u003e` - Returns an array of display objects.\n\nExample usage:\n```js\nconst displays = require('node-mac-displays')\n\nconst allDisplays = displays.getAllDisplays()\n\nconsole.log(allDisplays[0])\n/* Prints:\n[\n  {\n    id: 69734406,\n    name: 'Built-in Retina Display',\n    refreshRate: 0,\n    supportedWindowDepths: [\n      264, 516, 520, 528,\n      544,   0,   0,   0\n    ],\n    isAsleep: false,\n    isMonochrome: false,\n    colorSpace: { name: 'Color LCD', componentCount: 3 },\n    depth: 520,\n    scaleFactor: 2,\n    bounds: { x: 0, y: 0, width: 1680, height: 1050 },\n    workArea: { x: 0, y: 23, width: 1680, height: 932 },\n    rotation: 0,\n    internal: true\n  }\n]\n*/\n```\n\n### `displays.getPrimaryDisplay()`\n\nReturns `Object` - the display containing the window with the keyboard focus.\n\nExample Usage:\n```js\nconst displays = require('node-mac-displays')\n\nconst primary = displays.getPrimaryDisplay()\n\nconsole.log(primary)\n/* Prints:\n{\n  id: 69734406,\n  name: 'Built-in Retina Display',\n  refreshRate: 0,\n  supportedWindowDepths: [\n    264, 516, 520, 528,\n    544,   0,   0,   0\n  ],\n  isAsleep: false,\n  isMonochrome: false,\n  colorSpace: { name: 'Color LCD', componentCount: 3 },\n  depth: 520,\n  scaleFactor: 2,\n  bounds: { x: 0, y: 0, width: 1680, height: 1050 },\n  workArea: { x: 0, y: 23, width: 1680, height: 932 },\n  rotation: 0,\n  internal: true\n}\n*/\n```\n\n### `displays.getDisplayByID(id)`\n\n* `id` Number - The device ID for the display.\n\nReturns `Object` - the display with the specified device ID.\n\nExample Usage:\n```js\nconst displays = require('node-mac-displays')\n\nconst display = displays.getDisplayByID(2077749241)\n\nconsole.log(display)\n/* Prints:\n{\n  id: 69734406,\n  name: 'Built-in Retina Display',\n  refreshRate: 0,\n  supportedWindowDepths: [\n    264, 516, 520, 528,\n    544,   0,   0,   0\n  ],\n  isAsleep: false,\n  isMonochrome: false,\n  colorSpace: { name: 'Color LCD', componentCount: 3 },\n  depth: 520,\n  scaleFactor: 2,\n  bounds: { x: 0, y: 0, width: 1680, height: 1050 },\n  workArea: { x: 0, y: 23, width: 1680, height: 932 },\n  rotation: 0,\n  internal: true\n}\n*/\n```\n\n### `displays.mirror(enable, firstID[, secondID])`\n\n* `enable` Boolean - Whether to enable or disable mirroring.\n* `firstID` Number - The device ID for the primary display. If no second display ID is provided, the first\n display will default to the system's main display and the display corresponding to this ID will be set as the mirroring display.\n* `secondID` Number (optional) - The device ID for the secondary display (which will mirror the first).\n\nExample Usage:\n```js\nconst displays = require('node-mac-displays')\n\nconst [firstDisplay, secondDisplay] = displays.getAllDisplays()\n\n// Set the second display to mirror the first.\ndisplays.mirror(true, firstDisplay.id, secondDisplay.id)\n```\n\n### `displays.screenshot(id, options)`\n\n* `id` Number - The device ID for the display.\n* `options` Object\n  * `type` String - The representation of the image. Can be 'jpeg', 'png', or 'tiff'. Defaults to 'jpeg'.\n  * `bounds` Object\n    * `x` Number - The x coordinate of the origin of the rectangle.\n    * `y` Number - The y coordinate of the origin of the rectangle.\n    * `width` Number - The width of the rectangle.\n    * `height` Number - The height of the rectangle.\n\nReturns `Buffer` - a Buffer representation of the desired display screenshot.\n\nTakes a screenshot of the display with the specified id.\n\nExample Usage:\n```js\nconst displays = require('node-mac-displays')\nconst fs = require('fs')\nconst path = require('path')\n\nconst { id } = displays.getPrimaryDisplay()\n\nconst ssPath = path.resolve(__dirname, 'screenshot.jpg')\nconst screenshotData = displays.screenshot(id, {\n  bounds: {\n    x: 100,\n    y: 500,\n    width: 200,\n    height: 200\n  }\n})\n\n// Write out JPEG image as screenshot.jpg in the current directory.\nfs.writeFileSync(ssPath, screenshotData)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebytere%2Fnode-mac-displays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebytere%2Fnode-mac-displays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebytere%2Fnode-mac-displays/lists"}