Skip to main content

A CLI tool to temporarily block websites by modifying the hosts file

Project description

StopWeb

Block websites temporarily to help you stay focused. Works by editing your system's hosts file.

I built this because I kept getting distracted by social media and news sites when trying to work. Simple solution: block them for a few hours.

What it does

  • Blocks websites for a set amount of time (default: 1 day)
  • Automatically unblocks them when time's up
  • Works on Mac, Linux, and Windows
  • Lets you see what's currently blocked
  • Can unblock sites early if needed

Install

pip install stopweb

Basic usage

Block Facebook for a day:

sudo stopweb facebook.com

Block YouTube for 2 hours:

sudo stopweb --duration 2h youtube.com

Block multiple sites at once:

sudo stopweb facebook.com youtube.com reddit.com

See what's blocked:

sudo stopweb --list

Unblock a site early:

sudo stopweb --remove facebook.com

Remove all blocks:

sudo stopweb --clear

Time formats

  • 30m - 30 minutes
  • 2h - 2 hours
  • 1d - 1 day
  • 1w - 1 week

How it works

StopWeb edits your hosts file to redirect blocked sites to localhost (127.0.0.1).

On Mac/Linux that's /etc/hosts, on Windows it's C:\Windows\System32\drivers\etc\hosts.

It adds lines like:

127.0.0.1    facebook.com    # StopWeb: expires 2024-01-15 14:30:00

When the time expires, it removes those lines automatically.

Notes

  • Requires sudo/admin privileges (needs to edit system files)
  • You might need to clear your browser cache after blocking/unblocking
  • Creates a backup of your hosts file before making changes
  • If something goes wrong, your original hosts file is saved as hosts.stopweb_backup

Why not just use browser extensions?

Browser extensions can be easily disabled when you're feeling weak. Editing the hosts file is more permanent - you'd have to remember the exact command to undo it.

Plus this works system-wide, not just in your browser.

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

stopweb-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

stopweb-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file stopweb-0.1.0.tar.gz.

File metadata

  • Download URL: stopweb-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.7 Darwin/24.1.0

File hashes

Hashes for stopweb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 50dc3b53ab2a966ac4e7c44ad2833cace662f897123ba7ec56bb66360ace6b5e
MD5 3621cacaa5231de88b94dee623d44ab2
BLAKE2b-256 9e5b27a247e01ff9561fe18381ec216f69b1fbe0b1cb9ba7cc5f65df8c4d6ac7

See more details on using hashes here.

File details

Details for the file stopweb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stopweb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.7 Darwin/24.1.0

File hashes

Hashes for stopweb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e23cb0b1b8f1dec9ae4d823609d65f52d2263603f6d342246bf5ce693f7d41e0
MD5 ba7434b84ac9278160d2099019b98528
BLAKE2b-256 083546aef33e7926370627c61317e65c5e40c412647bac46d513923faa18fc78

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