How can I get SelfControl to always run?

Yes. Simply open System Preferences from the /Applications folder, select "Accounts" and, with your user name highlighted in the list to the left, select the "Login items" tab. Either drag and drop SelfControl into the list, or click the "+" button and navigate to its location.

Then, SelfControl will always start up when you log in.


You'll need to download and install Daniel Jalkut's Usable Keychain Scripting to quickly and securely access your admin password in order to activate SelfControl.

Add password to Keychain

Open Keychain Access.app. Create a new password by typing Cmd-N or going to File » New Password Item... Under Keychain Item Name, type 'SelfControl.' Make up any Account Name in the next field, and in the Password field, type the password for your user account (the password you would use to authenticate anything in OS X). Click 'Add', and you should now have a new application password entitled 'SelfControl' in your Keychain.

Create the AppleScript

Paste the following contents (originally from here)to a new window of AppleScript Editor.app:

on run argv
 set defaultTime to 1440

 try
  set myTime to item 1 of argv as number
 on error
  set myTime to defaultTime
 end try

 tell application "Usable Keychain Scripting"
  tell current keychain
   set myPass to (password of first generic item ¬
    whose name contains "SelfControl")

   -- eliminate invisible characters, or "gremlins," from password
   set x to quoted form of myPass
   set myPass to do shell script "echo " & x & " | perl -pe 's/[^[:print:]]//g'"
  end tell
 end tell

 tell application "SelfControl" to activate

 tell application "System Events"
  tell process "SelfControl"
   tell slider of window "SelfControl" to set value to myTime
   click button "Start" of window "SelfControl"
  end tell
  tell window 1 of process "SecurityAgent"
   with timeout of 15 seconds
    repeat
     set tryAgain to false
     try
      set value of text field 2 of scroll area 1 of group 1 to myPass
     on error
      delay 1
      set tryAgain to true
     end try
     if not tryAgain then exit repeat
    end repeat
    click button 2 of group 2
   end timeout
  end tell
 end tell
end run

We set defaultTime to 1440 (i.e. 24 hours) here so you can automatically kick off SelfControl for the maximum time.

Now, from AppleScript Editor, save this file somewhere by pressing File » Save, e.g. /Users/your-username/SelfControl.scpt, which would be in our home folder. Remember that path.

Create the launchd entry

Then open your favourite text editor or the Property List Editor.app that comes with the Mac OS X Dev tools on Snow Leopard or is integrated into Xcode on Lion.

Either way, paste the following contents, but make sure to change the path to the script accordingly (it't the one we remembered above):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>my.selfcontrol.launcher</string>
    <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>/Users/your-username/SelfControl.scpt</string>
    </array>
    <key>StartInterval</key>
    <integer>86400</integer>
    <key>RunAtLoad</key>
    <false/>
    <key>KeepAlive</key>
    <false/>
</dict>
</plist>

Save this file with the .plist extension under /Users/your-username/Library/LaunchAgents/my.selfcontrol.launcher.plist. If the Library folder is hidden, you can open Finder, press CmdShiftG and paste ~/Library to open it.

Load the launchd entry

Finally, open a terminal and run:

launchctl load ~/Library/LaunchAgents/my.selfcontrol.launcher.plist

This will tell launchd to open the AppleScript and start SelfControl for twenty four hours every twenty four hours.

Since it's in ~/Library/LaunchAgents it will be loaded automatically when you log in. If you want your computer back, replace load in the above command with unload, then wait for the remaining SelfControl time to expire.


You can easily make SelfControl block for any length of time you want--although we don't offer an "infinite" setting, I think a year-long block achieves most of the same purpose. And you can always restart it then. To block for up to a year, first close SelfControl, then open Terminal and run these commands:

defaults write org.eyebeam.SelfControl MaxBlockLength -int 31556900
defaults write org.eyebeam.SelfControl BlockLengthInterval -int 432000

Reopen SelfControl, and the slider will go all the way up to a year (with 5-day intervals). You can do this trick with any block length and interval, although our display currently doesn't do years--it'll probably display that length in days or weeks instead.

For more information, see this article on our wiki. Note however that we cannot provide support if you screw up your computer in Terminal, so this is for pro users only. More information on tweaks like this will eventually be available on our new website.


Here is a small utility that helps to schedule SelfControl: https://github.com/andreasgrill/auto-selfcontrol With this you could easily create a schedule to run daily from 12am to 11.59pm. This utility directly uses the command line API of SelfControl and doesn't need to store your admin password in a file.