{"id":21175412,"url":"https://github.com/luckman212/display-is-sleeping","last_synced_at":"2026-05-20T03:36:04.466Z","repository":{"id":206744255,"uuid":"717600823","full_name":"luckman212/display-is-sleeping","owner":"luckman212","description":"Utility to report display sleep/wake status on macOS","archived":false,"fork":false,"pushed_at":"2023-11-12T02:09:15.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-06T12:31:12.705Z","etag":null,"topics":["displays","macos","shell-scripting","sleep"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luckman212.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-12T00:46:14.000Z","updated_at":"2023-11-12T02:04:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"9149afc9-fbe0-493e-942a-c26c225df81f","html_url":"https://github.com/luckman212/display-is-sleeping","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"70e0208d6187240e7a239f98971bcc0eed1189e0"},"previous_names":["luckman212/display-is-sleeping"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luckman212/display-is-sleeping","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdisplay-is-sleeping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdisplay-is-sleeping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdisplay-is-sleeping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdisplay-is-sleeping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckman212","download_url":"https://codeload.github.com/luckman212/display-is-sleeping/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdisplay-is-sleeping/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33244778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-20T03:30:51.439Z","status":"ssl_error","status_checked_at":"2026-05-20T03:30:49.443Z","response_time":356,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["displays","macos","shell-scripting","sleep"],"created_at":"2024-11-20T16:59:20.495Z","updated_at":"2026-05-20T03:36:04.439Z","avatar_url":"https://github.com/luckman212.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=icon.png width=128\u003e\n\n# display-is-sleeping\n\nThis is a small Objective-C program that will report the current sleeping/awake status of the attached displays. It makes use of the **NSWorkspace** [`ScreensDidSleep`][1] and [`ScreensDidWake`][2] Notifications, and uses a small LaunchAgent to subscribe to those events and keep the status current.\n\nThe program can be called on its own without arguments and will simply return a POSIX exit code of 0 (sleeping) or 1 (awake) to indicate the screen's status. So you can run something like:\n\n```bash\nif ! display-is-sleeping ; then echo \"screen is awake!\"; fi\n```\nor more concisely\n```bash\ndisplay-is-sleeping || echo \"screen is awake!\"\n```\n\n### Installation (and Uninstallation)\n\nClone this repo (if you don't know how to do that, click the green **Code** button above, then **Download ZIP**). Once you have the bits on your disk, open a Terminal in the directory that contains the cloned files and run the command below:\n\n```bash\n./setup.sh --install\n```\n\nThis will copy the binary to `/usr/local/bin` (you can use a different directory if you like, by editing the setup script and changing the `BINDIR` variable at the top). It also creates and starts up the LaunchAgent. From then on, you can use the `display-is-sleeping` command in your scripts.\n\nTo **Uninstall**, simply re-run the script, passing `--uninstall`:\n```bash\n./setup.sh --uninstall\n```\nThis will unload and remove the LaunchAgent, stop any background processes and remove the command itself from wherever it was installed.\n\n### Usage\n\nExample use in a script\n```bash\nif display-is-sleeping ; then\n  # ...put code here to run if the screen is dark\nelse\n  # ...code to run if the screen is awake\nfi\n```\n\nGet current status as a string (prints `true` or `false`)\n```bash\ndisplay-is-sleeping --status\n```\n\nPlease report any bugs or issues you encounter. This idea was inspired by [this AskDifferent post](https://apple.stackexchange.com/questions/466236/check-if-display-sleep-on-apple-silicon-in-bash).\n\n[1]: https://developer.apple.com/documentation/appkit/nsworkspacescreensdidsleepnotification\n[2]: https://developer.apple.com/documentation/appkit/nsworkspacescreensdidwakenotification\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckman212%2Fdisplay-is-sleeping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckman212%2Fdisplay-is-sleeping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckman212%2Fdisplay-is-sleeping/lists"}