Skip to content

Small utility to schedule start and stop times of SelfControl

License

Notifications You must be signed in to change notification settings

iSumitG/auto-selfcontrol

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Auto-SelfControl

Small utility to schedule start and stop times of SelfControl.

What is it for?

Auto-SelfControl helps you to create a weekly schedule for SelfControl. You can plan for every weekday if and when SelfControl should start and stop.

Install

  • SelfControl is required and should be installed in the application directory (however, custom paths are also supported).
  • Start SelfControl and backup your blacklist as it might get overridden by Auto-SelfControl.
  • Download Auto-SelfControl and copy/extract it to a directory on your Mac (e.g. ~/auto-selfcontrol).
  • Edit the config.json (see Configuration first).
  • Open Terminal.app and navigate to the directory. (e.g. cd ~/auto-selfcontrol).
  • Execute sudo python auto-selfcontrol.py to install Auto-SelfControl with the block-schedule defined in config.json. Important: If you change config.json later, you have to call the installation command again or Auto-SelfControl might not start at the right time!

Uninstall

  • Delete the installation directory of Auto-SelfControl
  • Execute the following command in the Terminal.app:
sudo rm /Library/LaunchDaemons/com.parrot-bytes.auto-selfcontrol.plist

Configuration

The following listing shows an example config.json file that blocks every Monday from 9am to 5.30pm and on every Tuesday from 10am to 4pm:

    {
        "username": "MY_USERNAME",
        "selfcontrol-path": "/Applications/SelfControl.app",
        "host-blacklist": [
            "twitter.com",
            "reddit.com"
        ],
        "block-schedules":[
            {
                "weekday": 1,
                "start-hour": 9,
                "start-minute": 0,
                "end-hour": 17,
                "end-minute": 30
            },
            {
                "weekday": 2,
                "start-hour": 10,
                "start-minute": 0,
                "end-hour": 16,
                "end-minute": 0
            }
        ]
    }
  • username should be the Mac OS X username.

  • selfcontrol-path is the absolute path to SelfControl.

  • host-blacklist contains the list of sites that should get blacklisted as a string array. Please note that the blacklist in SelfControl might get overridden and should be backed up before using Auto-SelfControl.

  • block-schedules contains a list of schedules when SelfControl should be started.

    • The weekday settings specifies the day of the week when SelfControl should get started. Possible values are from 1 (Monday) to 7 (Sunday). If the setting is null or omitted the blocking will be scheduled for all week days.
    • start-hour and start-minute denote the time of the day when the blocking should start, while end-hour and end-minute specify the time it should end. The hours must be defined in the 24 hour digit format. If the ending time is before the start time, the block will last until the next day (see example below).

    Please note that it is possible to create multiple schedules on the same day, as long as they are not overlapping. Have a look at the example below.

The following listing shows another example that blocks twitter and reddit every Sunday from 11pm til Monday 5am, Monday from 9am until 7pm and Monday from 10pm to 11pm:

    {
        "username": "MY_USERNAME",
        "selfcontrol-path": "/Applications/SelfControl.app",
        "host-blacklist":[
            "twitter.com",
            "reddit.com"
        ],
        "block-schedules":[
            {
                "weekday": 7,
                "start-hour": 23,
                "start-minute": 0,
                "end-hour": 5,
                "end-minute": 0
            },
            {
                "weekday": 1,
                "start-hour": 9,
                "start-minute": 0,
                "end-hour": 19,
                "end-minute": 0
            },
            {
                "weekday": 1,
                "start-hour": 22,
                "start-minute": 0,
                "end-hour": 23,
                "end-minute": 0
            }
        ]
    }

Troubleshooting

  1. ImportError: No module named Foundation

If you've installed python using homebrew you'll need to run pip install pyobjc or there are other options.

About

Small utility to schedule start and stop times of SelfControl

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%