Using an $8 smart outlet to avoid brainrot

2025-06

I wrote a small script that runs in the background, polling for the state of an $8 smart plug.

It's got a switch on the side to manually toggle the switch on and off. It connects to WiFi, so you can read the state of the plug via API.

When you turn the switch on, the script updates /etc/hosts to effectively block websites of your choosing:

127.0.0.1 www.twitter.com
127.0.0.1 x.com
127.0.0.1 instagram.com
127.0.0.1 youtube.com
127.0.0.1 reddit.com

You can plug the switch into any outlet, ideally one far away from you. Now, whenever I want to visit a website in my blocklist, I have to physically get up and turn off the switch. Alternatively, I could just manually edit /etc/hosts, but this additional step adds just enough friction to make me reconsider reflexively distracting myself.