{"id":21175410,"url":"https://github.com/luckman212/dstat","last_synced_at":"2025-10-16T04:34:01.975Z","repository":{"id":206855193,"uuid":"717829945","full_name":"luckman212/dstat","owner":"luckman212","description":"CLI tool to query the screen sleep or lock status","archived":false,"fork":false,"pushed_at":"2023-11-12T21:11:55.000Z","size":58,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T14:08:58.140Z","etag":null,"topics":["displays","macos","screen","security","shell-scripting","utility"],"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-12T18:23:12.000Z","updated_at":"2025-03-17T15:42:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"657fabb1-6d30-4379-b8ce-dff0da8a19ef","html_url":"https://github.com/luckman212/dstat","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"7808d2289c39a15be7c9cc49aa7433e379a529cf"},"previous_names":["luckman212/dstat"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/luckman212/dstat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdstat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdstat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdstat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdstat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckman212","download_url":"https://codeload.github.com/luckman212/dstat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckman212%2Fdstat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279154615,"owners_count":26115457,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","screen","security","shell-scripting","utility"],"created_at":"2024-11-20T16:59:19.584Z","updated_at":"2025-10-16T04:34:01.926Z","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# dstat\n\nThis is a small Objective-C program that reports the current sleeping/awake status of the screen or locked/unlocked status of the login session. It's self-contained Universal Binary that runs on Apple Silicon and Intel-based Macs.\n\nIt requires a single argument (`-s`/`--sleep`, or `-l`/`--lock`) to select which detail to query. The program does not produce any output, instead it returns an exit code to indicate the status. This makes it well-suited for integration with shell scripts.\n\nThe meaning of the exit codes are as follows:\n\n|exit code|meaning|\n|:---:|:---|\n|0|display is sleeping or locked|\n|1|display is NOT sleeping or locked|\n|2|invalid commandline argument|\n|3|error querying display status|\n|4|no login session (cannot operate in this condition)|\n\n### Install\n\n1. Download the latest [release](https://github.com/luckman212/dstat/releases)\n2. Unzip `dstat.zip` and copy the `dstat` program to a directory in your `$PATH` — if you're unsure, `/usr/local/bin` is a solid choice.\n3. Execute `dstat \u003carg\u003e` from your shell or scripting environment (bash, zsh, etc)\n\n### Usage\n\nShow help:\n```bash\ndstat -h\n```\n\nExample #1\n```bash\ndstat --lock 2\u003e/dev/null\ncase $? in\n  0) echo \"screen is locked\";;\n  1) echo \"screen is unlocked\";;\n  *) echo \"something went pear shaped\";;\nesac\n```\n\nExample #2\n```bash\ndstat -l \u0026\u0026 echo \"screen is locked\"\n```\n\nExample #3\n```bash\nif dstat --sleep; then\n  # display is sleeping\n  say \"time for bed\"\nfi\n```\n\n### Caveats\n\nThe tool uses APIs that interact with the active login session. Thus, it cannot function if there's nobody logged in to the system. An error code of `4` is returned in that scenario, so it can at least be detected by your script. If anyone knows of a way to query for the sleep status of the display while in a logged out state, please file a PR! :pray:\n\nPlease report any bugs or issues you encounter. This idea was inspired by [this AskDifferent post][1], and is a somewhat more efficient followup to an earlier solution I came up with: [display-is-sleeping][2].\n\n[1]: https://apple.stackexchange.com/questions/466236/check-if-display-sleep-on-apple-silicon-in-bash\n[2]: https://github.com/luckman212/display-is-sleeping\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckman212%2Fdstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckman212%2Fdstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckman212%2Fdstat/lists"}