8 Feb 2024

Extending Raycast: Building a Website Blocker

First of all, if you haven’t tried Raycast and you’re a MacOS user, make sure to try it out. Raycast is a replacement for Apple Spotlight – the thing you trigger with CMD+space – and it is incredibly useful.

When I’m working at my computer and not yet in a good state of flow, sometimes my fingers start typing in URLs from distracting websites before my conscious brain can decide against that. In the past I would use a tool called SelfControl to block these websites during certain timeframes.

SelfControl currently doesn’t have a Raycast extension, and I also don’t like the fact that SelfControl works with a countdown timer, during which you can’t disable it. Personally, I just want to enable and disable website blocking whenever, and I have sufficient discipline to not misuse this ease of toggling.

So I set out to build a Raycast extension that does just that. It only took a few hours; that’s how easy Raycast has made the developer experience around building extensions. It’s live in the Raycast store under the very descriptive name Website Blocker.

I won’t go into too much technical detail, but the blocking functionality works by adding websites to the /etc/hosts file. Updating this file requires admin privileges, hence the password prompt every time you toggle the blocker.

It’s really easy to manage the blocklist right from within Raycast.

It’s not perfect, as in, sometimes websites stick around in your local browser cache, but overall it works quite well.

If you end up using this, I’d be happy to receive your feedback by email. Good luck taking back control of your time and focus!