Unified helper scripts for running Cold Turkey Blocker from Windows Subsystem for Linux (WSL). The toolkit combines the original scheduled automation and manual control scripts into a single entry point, centralises config/state/logs, and keeps everything inside this repo.
- Single CLI (
scripts/ct.sh) for automated schedules and manual control. - Shared log file at
logs/cold-turkey.logplus lightweight state tracking. - Missed-action recovery to catch up after downtime, with optional
--dry-run. - Multiple block profiles via
--block, with per-block state files and wrappers. - Config validation (
validate) and upcoming schedule preview (next). - Built-in alias helper for quickly wiring
ct(or any name) into your shell.
- Windows 10/11 with Cold Turkey Blocker installed (tested with WSL).
- WSL distro with Bash 5+,
jq, and the Windows filesystem mounted at/mnt/c. - Cron (or Task Scheduler calling WSL) if you plan to run scheduled automation.
Install jq on Ubuntu/Debian-based distros:
sudo apt-get update && sudo apt-get install -y jqscripts/ct.sh– main entry point for automation and manual commands.config/blocks.example.json– index template; copy toconfig/blocks.jsonand point it at your block files.config/blocks/*.example.json– per-block templates you can clone intoconfig/blocks/<name>.json.logs/– runtime logs (logs/cold-turkey.log).state/– last-run timestamp and block status tracking (auto-created)..gitignore– excludes logs, state, and your real config.
-
Copy the index template and customise it:
cp config/blocks.example.json config/blocks.json
Update the
defaultkey to whichever block you want to run when--blockisn’t provided, and make sure theblocksmapping points at the files you create in the next step. -
Copy the per-block templates you need:
cp config/blocks/focus-mode.example.json config/blocks/focus-mode.json cp config/blocks/deep-work.example.json config/blocks/deep-work.json
For each block file you create:
block_namemust match the block name inside the Cold Turkey app.
ct_pathis optional; include it when a block needs a custom Cold Turkey executable (e.g. separate installs, portable copies, or a non-standard location) and omit it to use the script’s built-in Windows path detection.schedulesholds your time/action/day entries (times use 24hHH:MM, actions arestartorstop, days use short names e.g."Mon").
- (Optional) Symlink
scripts/ct.shinto your$PATHfor shorter commands.
# Run scheduled automation (intended for cron)
./scripts/ct.sh auto
# Manual overrides
./scripts/ct.sh start "Deep work sprint"
./scripts/ct.sh --block deep-work stop "Break time"
./scripts/ct.sh toggle "Context switch"
./scripts/ct.sh status
./scripts/ct.sh next 3
./scripts/ct.sh validate
./scripts/ct.sh --dry-run auto
./scripts/ct.sh alias --install
./scripts/ct.sh helpYou can point to an alternate config file with --config /path/to/config.json or by exporting CT_CONFIG=/path/to/config.json.
--block NAMEpicks a profile registered inconfig/blocks.json(defaults to thedefaultentry).--dry-runsimulates automation without invoking Cold Turkey or writing state.nextprints the next scheduled actions (pass a number for how many entries).validatechecks JSON structure, times, actions, and configured paths.statusreports the last recorded action fromstate/status*.txt; if you changed the block inside Cold Turkey itself, runstart/stoponce to resync.
Print or install an alias (defaults to ct) for quicker access:
# Just print the alias line
./scripts/ct.sh alias
# Install into your shell profile
./scripts/ct.sh alias --install --rc ~/.bashrc
# Or choose a different alias name and shell
./scripts/ct.sh alias --install --name ctlite --rc ~/.zshrcReload your shell (or run source on the profile) after installation.
- Create one JSON file per profile under
config/blocks/(use the*.example.jsonfiles as a starting point). - Register each block in
config/blocks.jsonwith a simple mapping from block id to file path. - Invoke them with
./scripts/ct.sh --block <id-or-block_name> .... You can pass either the key fromconfig/blocks.jsonor theblock_namestored in the block file. - State and log entries include the block name, and status/last-run files are stored per block.
Example files:
-
config/blocks.json{ "default": "focus-mode", "blocks": { "focus-mode": "blocks/focus-mode.json", "deep-work": "blocks/deep-work.json", "weekend-lite": "blocks/weekend-lite.json" } } -
config/blocks/focus-mode.json{ "block_name": "Focus Mode", "ct_path": "/mnt/c/Program Files/Cold Turkey/Cold Turkey Blocker.exe", "schedules": [ { "description": "Weekday deep work start", "action": "start", "time": "09:00", "days": ["Mon", "Tue", "Wed", "Thu", "Fri"] }, { "description": "Lunch break", "action": "stop", "time": "12:30", "days": ["Mon", "Tue", "Wed", "Thu", "Fri"] }, { "description": "Afternoon focus", "action": "start", "time": "13:30", "days": ["Mon", "Tue", "Wed", "Thu", "Fri"] }, { "description": "Wrap up for the day", "action": "stop", "time": "18:00", "days": ["Mon", "Tue", "Wed", "Thu", "Fri"] } ] } -
config/blocks/deep-work.json{ "block_name": "Deep Work", "schedules": [ { "description": "Deep focus kickoff", "action": "start", "time": "06:30", "days": ["Tue", "Thu"] }, { "description": "Deep focus pause", "action": "stop", "time": "11:00", "days": ["Tue", "Thu"] }, { "description": "Deep focus reprise", "action": "start", "time": "14:00", "days": ["Tue", "Thu"] }, { "description": "Deep focus close", "action": "stop", "time": "20:00", "days": ["Tue", "Thu"] } ] }
Add or modify block files as needed, then register them in config/blocks.json. The validate command checks every referenced block file.
- Use
CT_CONFIG=/path/to/config.json(or--config) to point at alternate configs without copying them into the repo. - Point
CT_LOG_FILE=/path/to/file.logto relocate logs. Directories are created automatically. - Set
CT_EXEC_PATHorCOLD_TURKEY_PATHto override the detected Windows executable for all blocks; per-blockct_pathentries can either be absolute Windows paths or WSL paths using~/or environment variables. ct_pathvalues are resolved when the script runs, so snippets like"~/bin/Cold Turkey Blocker.exe"or"$HOME/apps/ct.exe"work once the path exists.--blockalways accepts the block id fromconfig/blocks.json, but it also matches theblock_nameinside each block file for friendlier manual commands.
Add a cron job inside WSL (runs every minute):
* * * * * /bin/bash /home/youruser/ct-script/scripts/ct.sh auto >/dev/null 2>&1If you prefer Windows Task Scheduler, call wsl.exe with the same command. The script stores the last run timestamp in state/last-run.txt to replay missed actions after downtime.
- Main log:
logs/cold-turkey.log - Last automation run:
state/last-run.txt - Last known block status:
state/status.txt
Use tail -f logs/cold-turkey.log to monitor actions live. All log entries include timestamps, action types, and descriptions.
- Missing config error: copy
config/blocks.example.jsontoconfig/blocks.jsonand add block files underconfig/blocks/. - Executable not found: verify the
ct_pathsetting in the config matches your installation. - jq missing: install it via
sudo apt-get install jq. - Validation failures: run
./scripts/ct.sh validateto see which block or schedule needs attention. - Status command says "unknown": no actions have been recorded yet; run
startorauto(or use--dry-runto preview without changes).
Happy focus time!
Licensed under the MIT License.