A SelfControl Workaround

UPDATE:  I now use K9 on windows (a parental controls app that does the job for me : http://www1.k9webprotection.com/ ) (Posted since I saw some traffic to this page recently).

I recently made the switch from Mac OS X to Windows (I now own a 17'' XPS which is an absolute beast of a machine). I have recently developed a major habit of wasting my time on sites like reddit, facebook (the addiction is rather huge here), gizmodo, engadget and the like. To get work done, it was imperative I used my web browser lesser than usual. Luckily, I found one of the best apps ever written to boost productivity: SelfControl came to my rescue here. SelfControl allows you to type in a list of sites you want to block and you are all set. Essentially, the one stop solution for people with my problem.

I couldn't find a free app on Windows (which sucks) so I decided to go write my own. Of course, this doesn't even match the awesomeness that SelfControl packs in its UI (I use the command line and a text file for user input and SelfControl has absolutely the best user interface for the job) and I still don't have persistence across reboots etc working (* yet).

My "app" (a small script) reads in domains from .list.txt (you can change it in the script) and adds this one line to the System hosts file:    _user_submitted_domain_

and voila, site is blocked. For running the app, you need to supply no. of minutes blocked as a command line argument. So you would run:

python WinSelfControl.py #number_of_minutes

and it should go block it.

Of course, there are some quirks. For example: www.facebook.com is needed to block facebook. I initally added just facebook.com and it didn't work (probably my misunderstanding of how hosts files work).

Also, this app isn't persistent across shutdowns. If you shut-down in the middle of its execution, you will have to kick out the lines added to the hosts file yourself. So beware!

This was the product of a few hours and at last I can get back to productivity.

I have only tested this on a 64 bit Windows 7 machine. Also, this code looks like spaghetti code and it might break something. So no warranties there.
Source uploaded here: http://shriphani.com/scripts/WinSelfControl.py

5 responses to “A SelfControl Workaround”

  1. Foone

    Since you're changing the pages to point to localhost, and python has a simple webserver module, you should have the script run a local webserver serving a single page (as a 404 so it'll be at every URL) saying "GO BACK TO WORK" in big text.

    like http://nofunforyou.simpleanswer.org/

  2. Steve Lambert


    I'm the designer of SelfControl. If you ever get this fleshed out, let me know. I'd be happy to post it on my site!



  3. Daniel

    What are the odds of getting a UI for this? I'd love to have one (especially one similar to the original OS X UI because it's so simple).

  4. Parker Kuivila

    Hey there,

    I got a Python version (full GUI and everything) of SelfControl, called SelfRestraint working if you're interested. The project is up at http://parker.kuivi.la/projects/selfrestraint.html and is on GitHub as well (http://github.com/ParkerK/selfrestraint)

    Take care,
    Parker Kuivila

Leave a Reply