Skip to main content

kill your mac, let your sleep win

· 2 min read

I have built a small utilty for myself to help me go to bed on time, its been helping me so far. I distributed it on GitHub bra1nDump/kill-my-mac, try it out and let me know if this helps you too.

kill my mac and let me sleep

  • I want to got to bed at a consistent time for health, productivity, and social reasons
  • When I don't go to bed early, chances are I am coding / watching something on my mac
  • The system suggestions to 'go to bed' are too easy to ignore, I tune them out magically

How it works

  • Your computer will be shut down during hours 12am - 6am
  • 1 hour and 10 minutes before the sleep hours start the computer will warn you, if your sound is on
  • Open an issue if you want a feature to customize the sleep hours

How does it actually work?

  • It installs a LaunchAgent that runs shutdown-job every minute
    • You can find the agent configuration here ls ~/Library/LaunchAgents
  • shutdown-job.sh
    • If computer is already asleep (uses pmset), do nothing
    • If close to sleep hours, warns the user
    • If in sleep hours, shut down using apple script osascript -e 'tell application "System Events" to shut down'

Alternatives:

References: