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
- You can find the agent configuration here
- 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'
- If computer is already asleep (uses
Alternatives:
- Work on the discipline in other ways
pmset repeat shutdown TWRFS 11:00:00
- Almighty https://indiegoodies.com/almighty - many different shortcuts
References:
- I originally planned to distribute through brew. Turns out your project needs to be somewhat recognized on GitHub to be accepted: Your application’s Github repo should have more than 30 watchers, 75 stars and 30 watchers and should be more than 30 days old
- Originally found this limitation in this article: https://danishpraka.sh/posts/distribute-via-brew/