Skip to content

Instantly share code, notes, and snippets.

@billwallis
Created April 15, 2025 10:20
Show Gist options
  • Save billwallis/edb610e7584b6f3a480bce31ab75f1ea to your computer and use it in GitHub Desktop.
Save billwallis/edb610e7584b6f3a480bce31ab75f1ea to your computer and use it in GitHub Desktop.
Keep screen awake script using wakepy and uv
#!/your-path-to/.local/bin/uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "wakepy",
# ]
# ///
"""
Keep the screen awake.
- https://wakepy.readthedocs.io/en/stable/user-guide/index.html
"""
import datetime
import time
from wakepy import keep
SLEEP_TIME = 60 * 60 * 24 # 24 hours
def main() -> None:
with keep.presenting():
print(f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Keeping screen awake...")
time.sleep(SLEEP_TIME)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment