Skip to main content

Block websites with per-site daily time limits — hosts-based, daemon-enforced

Project description

bolok

bolok your distraction && focus your work

Block any website with a daily time limit. One timed session per day, then a 24-hour lockout — enforced at the OS level, survives reboots.

Works on macOS, Linux, and Windows. Pure Python, no dependencies, no browser extension, no account required.

How it works

bolok redirects domains to 0.0.0.0 via the system hosts file and keeps it in sync with a privileged background daemon that runs at boot and every 30 seconds.

  • Add any site to your list with a per-site daily limit in minutes.
  • bolok start opens a timed session — the site unblocks for that window.
  • When the session ends (by timeout or bolok stop) the site re-blocks for a full 24-hour lockout, measured from the moment the session ended.
  • Timers use absolute Unix timestamps, so sleep, reboot, or closing the terminal cannot extend a session.
  • bolok off <sitename> is always available as an escape hatch.

Facebook (25 domains) is pre-loaded. Add anything else with bolok list add.

Requirements

Platform Hosts file Daemon Extra
macOS /private/etc/hosts launchd Xcode CLT (xcode-select --install)
Linux /etc/hosts systemd Python 3.8+
Windows System32\drivers\etc\hosts Task Scheduler Python 3.8+, elevated terminal

Install

# macOS / Linux
pip install bolok
sudo bolok install

# Windows (elevated terminal)
pip install bolok
bolok install

From source / dev:

git clone https://github.com/pdfarhad/bolok.git && cd bolok
pip install -e .
sudo bolok install

Upgrade: pip install --upgrade bolok && sudo bolok install

Quick start

# Enable blocking for all sites (Facebook is pre-loaded)
bolok on -a

# See per-site state and time remaining
bolok status

# Start your daily session for the single/default site
bolok start

# Done early? End the session (starts the 24h lockout from now)
bolok stop

Managing your site list

# Show all sites with limits and current state
bolok list

# Add a site — short name auto-derived from the URL
bolok list add instagram.com 15       # 15 min/day
bolok list add https://twitter.com 20 # 20 min/day

# Update a site's daily limit
bolok list edit instagram 30

# Enable / disable blocking per site
bolok on instagram
bolok off instagram

All commands

bolok on <sitename>               enable blocking for one site
bolok on -a                       enable blocking for all sites
bolok off <sitename>              disable blocking for one site
bolok off -a                      disable blocking for all sites
bolok start [<sitename>]          begin the one daily session
bolok stop  [<sitename>] [--yes]  end session early (costs the full 24h lockout)
bolok status                      per-site state, countdowns, daemon health
bolok limit [<sitename>] <min>    set session length (1-1440 minutes)
bolok browsers "Browser Name"     close these browsers when a block starts
bolok browsers off                stop auto-closing browsers
bolok list                        show all sites
bolok list add <url> <minutes>    add a new site
bolok list edit <sitename> <min>  update a site's daily limit
sudo bolok reset                  emergency: unblock hosts and reset all state
sudo bolok uninstall              remove daemon and CLI, keep state files

Known limitations

  • macOS + Safari + iCloud Private Relay — Private Relay bypasses hosts-based blocking. Turn it off in System Settings, or use another browser.
  • Windows Defender / antivirus may flag hosts file modifications. Allow bolok if prompted; it only writes its own marker section.
  • Already-open tabs keep loading until the browser re-resolves DNS. Use bolok browsers "Firefox" to close browsers automatically at block time.
  • VPNs and proxies bypass it. This is friction, not a prison — you have admin rights. bolok off <sitename> is always available.
  • Domains are explicit. Adding a site blocks site.com, www.site.com, and m.site.com. Other subdomains are not covered unless added manually. Facebook's built-in list covers 25 domains across facebook.com, fb.com, and messenger.com.
  • Windows enforcement granularity is 1 minute (Task Scheduler minimum), vs 30 seconds on macOS and Linux.

Reboot persistence

The hosts file is a plain file on disk — block entries survive reboots. A privileged daemon re-enforces timer transitions that expired while the machine was off:

Platform Daemon Boot delay Interval
macOS launchd (RunAtLoad = true) immediate 30s
Linux systemd timer 5s 30s
Windows Task Scheduler on startup 60s

Development

pip install -e .                          # editable install
python3 -m unittest tests.test_bolok -v  # 64 unit tests (pure functions only)

Single-file codebase (bolok.py). All pure logic is unit-tested; the imperative layer (file I/O, daemon wiring) is kept thin and verified manually.

License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bolok-0.5.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bolok-0.5.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file bolok-0.5.0.tar.gz.

File metadata

  • Download URL: bolok-0.5.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for bolok-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f44369b7380cb58e0894ce4889322d91cbda306facdaf209fb27d131c46662e5
MD5 2aac3ae560e7b1b21ab6a5268ebcc8be
BLAKE2b-256 891389a33b8e858f0d199850282e0b732a905735a11886789c2ade06836d36c6

See more details on using hashes here.

File details

Details for the file bolok-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: bolok-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for bolok-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 122a43a1ca07677aa49450791afed7ad9829d0dba5597762d6a9fe946631253f
MD5 dde0a497df8bbec4f22150bdb176f9d2
BLAKE2b-256 b3da04a95af11c5f0ad2d70aa04ea4eefccc9664fd5dd665ef94a7174992840e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page