I wrote ‘hosts-timer’ to help quit my (desktop) Twitter and Facebook habits
Part of the Project Announcements series.
It was really easy for me to get into the habit of checking Facebook and Twitter while waiting for my computer to finish something. These sites are, after all, designed to be addicting.
There are some apps that are supposed to help solve this, but I figured I could build my own pretty quickly & easily, and for free. The result is a simple Go program: hosts-timer
. It works like this:
- First, install it for certain domains you’d like to restrict access to:
sudo hosts-timer -install facebook.com twitter.com
- Then, you can enable a site for a certain amount of time:
sudo hosts-timer -time 5m twitter.com
hosts-timer
unblocks the site, and waits until the specified time has elapsed (or until you kill it with Ctrl-C).- When
hosts-timer
exits, the site is blocked again.
Under the hood, the program works — as its name implies — by adding and removing entires in /etc/hosts
.
With this installed on all my computers, I’ve dramatically cut the amount of time I spend on Facebook and Twitter.
As documented in the project’s README, there are some tips & tricks to make usage easier:
- Set up some zsh (or bash) helpers,
use-facebook
anduse-twitter
, to make the day-to-day UX for this program a little better. - Set up some Alfred helpers, allowing temporary enabling of Facebook & Twitter via Alfred workflows.
- Create
/etc/sudoers.d/hosts-timer
, allowing your user to usehosts-timer
without typing your password forsudo
every time.
Hopefully this program is as useful for some of you as it has been for me.