A small Windows utility that schedules a system shutdown at a configured bedtime and enforces it by marking the process as critical ‒ thus, you won't be able to terminate the bedtime process right before bedtime and override it. If you do, the system will BSOD. No more staying on your computer past reasonable bedtime!
Inspired by the awesome kgotobed ‒ this tries to be something as similar as possible in effect for Windows.
The reason why kgotobed was made is pretty much the reason I made this too:
Night owls feel most creative and energetic late at night, which makes it hard for some to break the flow and go to bed. If I’m working on something exciting I will find myself going to sleep very late and then feeling shitty and sleep deprived on the following day.
I still want to go to sleep at a reasonable time. I tried different methods, from alarm clocks as reminders to cron jobs that will shut down the computer. They weren’t effective in the long term because they are just too easy to ignore: Snooze that alarm! Kill that crond! I need 10 more minutes! Come on, I’m at my peak now, I don’t want to stop! Oh, it’s 3 AM again?
- Reads a shutdown time from a JSON config file
- Waits until the target time and then initiates a Windows shutdown
- Uses the Windows API to mark the running process as critical while the shutdown timer is active
- Optionally writes status messages to a log file
bedtime_shutdown.py— main scheduling and shutdown logicbedtime_config.json— default configuration valuesCriticalProcess/— submodule that implements the low-level Windows critical-process behavior
- Windows 10 or Windows 11
- Python 3.9+
- Administrator privileges
-
Clone the repository:
git clone <your-repository-url> cd bedtime-windows
-
Make sure the submodule is initialized:
git submodule update --init --recursive
The default config file is bedtime_config.json and looks like this:
{
"shutdown_time": "22:00",
"addict_mode": false
}Optionally, you can enable logging by adding log_file:
{
"shutdown_time": "22:00",
"addict_mode": false,
"log_file": "bedtime.log"
}shutdown_time: target shutdown time inHH:MM24-hour formataddict_mode: whentrue, the script will trigger an additional shutdown in 10 minutes if it starts within four hours after the configured bedtime windowlog_file: optional path for log output
Run the script from an elevated terminal:
python bedtime_shutdown.pyUse the included installer script to create a per-user task that runs at every logon using pythonw.exe and starts in the repository directory:
powershell -ExecutionPolicy Bypass -File .\install_task.ps1This creates a scheduled task named BedtimeWindows that launches the script from the repo root as a background process without opening a console window.
python bedtime_shutdown.py --time 22:00
python bedtime_shutdown.py --config bedtime_config.json
python bedtime_shutdown.py --addict-mode
python bedtime_shutdown.py --no-addict-mode
python bedtime_shutdown.py --log-file "C:/logs/bedtime_shutdown.log"
python bedtime_shutdown.py --no-log-file
python bedtime_shutdown.py --no-force