{"id":22292275,"url":"https://github.com/locka99/stayawake","last_synced_at":"2025-03-25T21:46:24.828Z","repository":{"id":233340489,"uuid":"787072019","full_name":"locka99/stayawake","owner":"locka99","description":"Windows user activity simulator","archived":false,"fork":false,"pushed_at":"2024-04-16T16:37:09.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T19:15:00.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/locka99.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-15T20:47:43.000Z","updated_at":"2024-04-15T20:50:03.000Z","dependencies_parsed_at":"2024-12-03T17:21:24.409Z","dependency_job_id":"19fed650-4c62-4cdf-bcc0-1117fb07cb83","html_url":"https://github.com/locka99/stayawake","commit_stats":null,"previous_names":["locka99/stayawake"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locka99%2Fstayawake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locka99%2Fstayawake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locka99%2Fstayawake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locka99%2Fstayawake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/locka99","download_url":"https://codeload.github.com/locka99/stayawake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245550540,"owners_count":20633872,"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-12-03T17:20:46.231Z","updated_at":"2025-03-25T21:46:24.799Z","avatar_url":"https://github.com/locka99.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stayawake\n\nThe `stayawake` program sends a F15 keypress on a 30 second timer interval to stop Windows sleeping. F15 is\nchosen since it is rarely mapped to anything yet still counts as activity.\n\nThe program shows an icon in the tray when it is running and the program can be terminated from the tray.\n\nIt might be useful for testing purposes (e.g. automation tests) where screen locking interferes with the test\nor when you want to override the default sleep behaviour of a computer. e.g. maybe you have a remote desktop\ninside of a physical desktop and don't want the remote desktop to go to sleep all the time.\n\n## Rust\n\nCode is written in Rust, so building / running should be as simple as:\n\n```sh\ncargo build --release # or\ncargo run --release\n```\n\nIt should build with either MSVC or GNU backends, i.e. `stable-x86_64-pc-windows-msvc` or `stable-x86_64-pc-windows-gnu`. You will require a Windows resource compiler, either `rc.exe` or `windres` in your path depending on MSVC or GNU (MSYS2).\n\nThe release build is optimized for size, \u003c 250Kb depending on toolchain.\n\n### Win32 in Rust appraisal\n\nThe code uses the Microsoft auto generated bindings for Win32.\n\nI've written plenty of Win32 in C and C++ and just wanted to experience the Rust bindings to see how they work. Generally speaking they're okay and\noffer some simple safeguards over raw Win32, e.g. structures have default initialisers, functions with optional parameters will use Option\u003c\u003e instead of null, and even handles have some basic protections to avoid casting.\n\nThere are a few downsides I encountered - Rust supports unions in unsafe structs which is fine but initialising them seems clumsy. In addition, some macros that exist in C/C++ through header files just aren't here. e.g. MAKEINTRESOURCE() is nowhere to be found, and also helpers LOWORD(), HIWORD() etc.\n\nOverall I thnk the bindings are pretty decent and do allow safer programming (even in `unsafe` blocks) since it's harder to miss a parameter or inadvertently pass in junk. At the same time, Win32 is horribly inconsistent so there are structs that have cbSize fields that need to be initialized or weird combinations of args or flags\nthat don't make obvious sense unless you read the docs. So all that remains and could be dangerous.\n\nAlso this particular program is 90% Win32 so it doesn't benefit as much from being written in Rust as another program might. I think if the program had more application logic away from Win32, that the benefits of safe programming would be instantly felt.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocka99%2Fstayawake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocka99%2Fstayawake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocka99%2Fstayawake/lists"}