I use the SelfControl app.

Is there a way to make it always run?

4 Answers 4


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

  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
     set tryAgain to false
      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">

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.

  • SelfControl has a 24 hour duration limit on enabling its functionality. That's probably more relevant..?
    – Daniel Beck
    Mar 30, 2011 at 7:51
  • Fair enough, but I don't think a downvote is a reasonable response to the original poster asking an ambiguous question.
    – Scott
    Mar 30, 2011 at 9:02
  • I didn't downvote and don't know who did, although it's a reasonable assumption after my comment. Pity the downvoter didn't bother to comment himself. Upvote for the edited answer, clearly a lot better.
    – Daniel Beck
    Mar 30, 2011 at 9:22
  • 2
    In that case, I shall rail against people downvoting without leaving an explanation!
    – Scott
    Mar 30, 2011 at 9:44
  • Glad to hear it, Mark. *blows raspberry at downvoter*
    – Scott
    Mar 31, 2011 at 20:21

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.

  • Shouldn't a year be 525600 minutes? And a 5-day interval 7200? Oct 29, 2015 at 14:37

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.

  • 1
    Why was this voted down? It's great. Sep 13, 2016 at 17:34

Another option is to set up a cronjob for selfcontrol. This has to be done from the terminal by someone with administrator privileges. To do this first type

id -u $USER

and remember the number, Say XXXX. Next open the root crontab file with

sudo crontab -e

You will be prompted for your password and this will only work from an administrators' account. Now add the following lines (the first two lines are comments explaining the last line):

# Cron syntax: minute hour day_of_month month day_of_week <command>
# Run self-control at 11pm every day for user XXXX = $(id -u $USER)
0 23 * * * /Applications/SelfControl.app/Contents/MacO/org.eyebeam.SelfControl XXXX --install

where XXXX is the number you obtained in the first step. If you wanted to automatically run selfcontrol from 8:30am Monday-Friday then the start of the crontab line would be

30 10 * * 1-5 /Applications/...

You can add as many crontab lines as you like to schedule arbitrary commands to run at different times. Btw, by default, you will be editing the crontab file using vi, so you can save the file using ZZ, for example.

The advantage of running Selfcontrol as a root cronjob is that this way it already has "administrator rights" (root access), and there is not need to give it an administrator's password. Selfcontrol will run with the current settings. You can see these either using the selfcontrol app or from the command-line using

defaults read org.eyebeam.SelfControl

Similarly, you can modify the settings using defaults write ..., so you could ensure that selfcontrol runs with the settings that you want by adding another cronjob to set-up selfcontrol just before it starts. For example, adding the line

59 22 * * * /usr/bin/defaults write org.eyebeam.SelfControl BlockDuration 420

will set the duration that selfcontrol runs to 7 hours at 22:59 each day.

  • 1
    or sudo crontab -e and then replace everything in <>s in the following: 30 10 * * 1-5 sudo -H -u <your_username> /usr/bin/defaults write org.eyebeam.SelfControl BlockDuration <length_in_minutes> && /Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl <user_id_number> --install Mar 5, 2018 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.