Giter Club home page Giter Club logo

auto-selfcontrol's People

Contributors

andreasgrill avatar jondeaton avatar raybb avatar sbibauw avatar tobinsouth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto-selfcontrol's Issues

Auto-SelfControl on boot

Is it normal, that i have to activate auto-self control after every boot? Or to have to add it to chronjob?

Wrong version of PyObjC C API

Hi Andreas, I'm having this problem after running sudo /usr/bin/python auto-selfcontrol.py:

Traceback (most recent call last):
File "auto-selfcontrol.py", line 10, in
from Foundation import NSUserDefaults, CFPreferencesSetAppValue, CFPreferencesAppSynchronize, NSDate
File "/Library/Python/2.7/site-packages/pyobjc_framework_Cocoa-3.2.1-py2.7-macosx-10.12-intel.egg/Foundation/init.py", line 9, in
import CoreFoundation
File "/Library/Python/2.7/site-packages/pyobjc_framework_Cocoa-3.2.1-py2.7-macosx-10.12-intel.egg/CoreFoundation/init.py", line 22, in
import CoreFoundation._CoreFoundation
RuntimeError: Wrong version of PyObjC C API (got 19, expected 20)
Hope you can help.

Small Typo in README.md

In the following line in the readme file:

Execute /usr/bin/python setup.py install to install the packages required to run Auto-SeltControl.

There is a small typo on "Auto-SelfControl".

Additionally, for new command line users like me, it may not be obvious that you have to add sudo to that line of command to make it run (It took me a while to figure it out). Thus, the line should be:

Execute sudo /usr/bin/python setup.py install to install the packages required to run Auto-SelfControl.

Thank you!

install doesn't work

~/auto-selfcontrol $ sudo /usr/bin/python setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing requirements to auto_selfcontrol.egg-info/requires.txt
writing auto_selfcontrol.egg-info/PKG-INFO
writing top-level names to auto_selfcontrol.egg-info/top_level.txt
writing dependency_links to auto_selfcontrol.egg-info/dependency_links.txt
reading manifest file 'auto_selfcontrol.egg-info/SOURCES.txt'
writing manifest file 'auto_selfcontrol.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.13-intel/egg
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build/bdist.macosx-10.13-intel/egg
creating build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying auto_selfcontrol.egg-info/PKG-INFO -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying auto_selfcontrol.egg-info/SOURCES.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying auto_selfcontrol.egg-info/dependency_links.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying auto_selfcontrol.egg-info/requires.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying auto_selfcontrol.egg-info/top_level.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/auto_selfcontrol-1.0-py2.7.egg' and adding 'build/bdist.macosx-10.13-intel/egg' to it
removing 'build/bdist.macosx-10.13-intel/egg' (and everything under it)
Processing auto_selfcontrol-1.0-py2.7.egg
Removing /Library/Python/2.7/site-packages/auto_selfcontrol-1.0-py2.7.egg
Copying auto_selfcontrol-1.0-py2.7.egg to /Library/Python/2.7/site-packages
auto-selfcontrol 1.0 is already the active version in easy-install.pth

Installed /Library/Python/2.7/site-packages/auto_selfcontrol-1.0-py2.7.egg
Processing dependencies for auto-selfcontrol==1.0
Searching for pyobjc
Reading https://pypi.python.org/simple/pyobjc/
Best match: pyobjc 5.1.2
Downloading https://files.pythonhosted.org/packages/2c/23/fb8b1fc0ed318c53007e1030489617b3ccb43cac21e02e0aae02e97970e4/pyobjc-5.1.2.tar.gz#sha256=ccfc96382bf04977c68a06733f1d7499a7ddeb1f74760e3f8de483f9a542e691
Processing pyobjc-5.1.2.tar.gz
Writing /tmp/easy_install-ihVmYl/pyobjc-5.1.2/setup.cfg
Running pyobjc-5.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ihVmYl/pyobjc-5.1.2/egg-dist-tmp-nDT9Xs
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
error: Setup script exited with error in pyobjc setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected ',' or end-of-list in pyobjc-framework-libdispatch==5.1.2;platform_release>="12.0" at ;platform_release>="12.0"

Cannot install the package.

I tried installing the package and its failing with the following error
Modules/_Vision.m:6:9: fatal error: 'Vision/Vision.h' file not found #import <Vision/Vision.h> ^ 1 error generated.

I Have python 3.5 installed in my machine.

NameError: name 'platform_release' is not defined

Hi,

I'm trying to install your app -- thanks very much for creating this! When I run the commend "/usr/bin/python setup.py install" in the auto-selfcontrol directory, I get the following error. I have tried installing pyobjc with Pip, but that does not seem to address the error. I also wasn't able to find 'platform_release" in the setup.py file, so I'm not sure how to fix this error. Any help would be much appreciated! Thank you!

The error message is as follows:

Processing dependencies for auto-selfcontrol==1.0
Traceback (most recent call last):
File "setup.py", line 11, in
install_requires=["pyobjc", "pyobjc-core"]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/install.py", line 117, in do_egg_install
cmd.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 389, in run
self.easy_install(spec, not self.no_deps)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 619, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 670, in install_item
self.process_distribution(spec, dist, deps)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 718, in process_distribution
[requirement], self.local_index, self.easy_install
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 854, in resolve
new_requirements = dist.requires(req.extras)[::-1]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 2617, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 2818, in _dep_map
self.__dep_map = self._compute_dependencies()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 2851, in _compute_dependencies
common = frozenset(reqs_for_extra(None))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 2848, in reqs_for_extra
if req.marker_fn(override={'extra':extra}):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py", line 113, in marker_fn
return eval(compiled_marker, environment)
File "", line 1, in
NameError: name 'platform_release' is not defined

Scheduling for 30 mins 'from now'

First - absolutely awesome that you created this - thanks Andreas

I want to be able to schedule for Selfcontrol to kick in 30 mins from now - short-term myopia means it's easier to commit to the app activating in the future than now

I'm happy to fork and work on the change, but I'm wondering if you had plans to work on this or had a workaround with the existing code

Error while launching

2019-06-09 00:47:03.266 org.eyebeam.SelfControl[87299:32168349] Using your own bundle identifier as an NSUserDefaults suite name does not make sense and will not work. Break on _NSUserDefaults_Log_Nonsensical_Suites to find this
2019-06-09 00:47:05.898 org.eyebeam.SelfControl[87299:32168349] INFO: Block successfully added.

Whitelist doesnt work

Hi Andreasgrill, I would greatly appreciate an explanation on how to make whitelisting properly work. I tried the ''whitelist..: true, but that didn't do it for me. Thanx ahead

No username specified in config.

Changed username(my mac's username) and specified username both in config.json.

Use system python 2.7. Via sudo. Tried Pyobjc.

still shows:

ERROR:
No username specified in config.

google.com takes few minutes to get blocked

So once I have activated it, I tried to remove entries from hosts file and then all entries were added back for sure but in Safari browser google.com still opens up and it is in blacklist. Other sites like reddit and twitter also opens up for a while like in 2 to 5 seconds it will be blocked again and will not open. But google.com will work for more than a minute or so. I don't understand what is happening under hood.

Username 'MY_USERNAME' unknown.

Try to run it and get this error message. It suggests me using whoami to learn the username. However, it shows the same username I used for config. Specific below:
Username 'anhnguyen' unknown. Please use your OSX username instead. If you have trouble finding it, just enter the command 'whoami' in your terminal. Anhs-MacBook-Pro:auto-selfcontrol-master anhnguyen$ whoami anhnguyen

Anyone has any ideas what is the problem?

Edit /etc/hosts and it doesn't block sites anymore

So I found this behaviour that when I edited hosts file (in Mac Os Big Sur) then it would not block the sites whereas in SelfControl app if you activate the timer and then edit the hosts file even then also it would block sites as it will again add those site in hosts file automatically, but this doesn't happen in auto-selfcontrol. Please someone fix this issue.

API v3 Uncaught exception

Thank you for this useful tool. I just upgraded selfcontrol and auto-selfcontrol (using brew) and then i run: auto-selfcontrol activate

I get the following exception and it doesn't run selfcontrol nor apply the blocklist.

> Active schedule found for SelfControl!
> Start SelfControl (this could take a few minutes)

> Detected API v3
Uncaught exception:
<class 'subprocess.CalledProcessError'>
Command '['/Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl', '501', '--install', '/usr/local/etc/auto-selfcontrol/blocklist', '2020.05.23T12:00:00--700']' returned non-zero exit status 74
Traceback (most recent call last):
  File "/usr/local/bin/auto-selfcontrol.py", line 446, in <module>
    run(SETTINGS_DIR)
  File "/usr/local/bin/auto-selfcontrol.py", line 97, in run
    run_api_v3(config, settings_dir)
  File "/usr/local/bin/auto-selfcontrol.py", line 168, in run_api_v3
    execSelfControl(config, ["--install", blocklist_path, block_end_date])
  File "/usr/local/bin/auto-selfcontrol.py", line 322, in execSelfControl
    stderr=subprocess.STDOUT
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['/Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl', '501', '--install', '/usr/local/etc/auto-selfcontrol/blocklist', '2020.05.23T12:00:00--700']' returned non-zero exit status 74

Block list

Hi, great little app! I wonder if it's possible to use a saved block list.

Best
d

Allowed sites

If I want to add a new site to the whitelist while selfcontrol is running, is it as easy as changing the config.json?

Whitelist bogs down the internet

I tried to use a whitelist with a few websites, and then the internet became highly unreliable. It was difficult to do Zoom calls and other internet connections. Just want to flag this.

Failing to start block when waking from sleep

Hi,

Upon waking the computer, often the block fails to start.
This occurs when the computer went to sleep during a previous block - for instance, if the computer went to sleep during a block from 9pm to 7am, and is then woken during a block from 9am to 6pm.
Looking at the syslog, I found the following:

Aug 13 10:46:45 georges-mbp Auto-SelfControl: 
[ERROR] SelfControl is already running, ignore current execution of Auto-SelfControl.

Aug 13 10:46:45 georges-mbp com.apple.xpc.launchd[1] (com.parrot-bytes.auto-selfcontrol[73333]): 
Service exited with abnormal code: 2

It seems that upon wakeup the auto-selfcontrol script is run before the SelfControl daemon has a chance to clear itself.

It doesn't seem that the macOS launchctl utility has many options for starting daemons at a delay after wakeup etc, so I went for the simple solution of putting

time.sleep(1)

in the main function for the script.
This should hopefully give the SelfControl daemon time to remove itself.

Possibly you might want a more elegant solution, but if it works I'll submit a PR anyway.

Won't block my sites at specified time

Thank you for making this!

Problem: I followed the installation instructions, but at the specified time, I can still access my blocked sites

My settings are this:

{
"username": "MY_USERNAME",
"selfcontrol-path": "/Applications/SelfControl.app",
"host-blacklist": [
"twitter.com",
"reddit.com"
],
"block-schedules":[
{
"weekday": 1,
"start-hour": 17,
"start-minute": 0,
"end-hour": 17,
"end-minute": 2
},
{
"weekday": 1,
"start-hour": 17,
"start-minute": 4,
"end-hour": 17,
"end-minute": 6
},
]
}

when i install the python file, i get this:

Traceback (most recent call last):
File "auto-selfcontrol.py", line 10, in
from Foundation import NSUserDefaults, CFPreferencesSetAppValue, CFPreferencesAppSynchronize, NSDate
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/Foundation/init.py", line 8, in
import objc
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/init.py", line 28, in
from objc._bridgesupport import *
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 13, in
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 72, in
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: call() takes exactly 2 arguments (1 given)

Notice that it ends in an error - maybe that is a reason why?

getting errors when trying to run

Tested a variety of ways to work this, but kept getting errors.

If I have a config.json like it is as default:

{
"username": "steve",
"selfcontrol-path": "/Applications/SelfControl.app",
"legacy-mode": true,
"host-blacklist": [
    "twitter.com",
    "reddit.com"
],
"block-schedules":[
    {
        "weekday": 1,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0,
        "block-as-whitelist": false,
        "host-blacklist": null
    },

... etc ...

I get an error like this:

> Start installation of Auto-SelfControl
Uncaught exception:
<type 'exceptions.TypeError'>
'int' object is not iterable
Traceback (most recent call last):
  File "auto-selfcontrol.py", line 206, in <module>
    install(config)
  File "auto-selfcontrol.py", line 170, in install
    launchplist_script = get_launchscript(config)
  File "auto-selfcontrol.py", line 139, in get_launchscript
    </plist>'''.format(path=os.path.realpath(__file__), startintervals="".join(get_launchscript_startintervals(config)))
  File "auto-selfcontrol.py", line 145, in get_launchscript_startintervals
    for weekday in list(schedule["weekday"]) if schedule.get("weekday", None) is not None else range(1,8):
TypeError: 'int' object is not iterable

If I populate the host-blacklist instead of leaving it null:

{
"username": "steve",
"selfcontrol-path": "/Applications/SelfControl.app",
"legacy-mode": true,
"host-blacklist": [
    "twitter.com",
    "reddit.com"
],
"block-schedules":[
    {
        "weekday": 1,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0,
        "block-as-whitelist": false,
        "host-blacklist": "twitter.com","facebook.com"
    },

... etc ...

And run the script I get:

Uncaught exception:
<type 'exceptions.ValueError'>
Expecting : delimiter: line 18 column 9 (char 469)
Traceback (most recent call last):
  File "auto-selfcontrol.py", line 201, in <module>
    config = load_config([os.path.join(__location__,"config.json")])
  File "auto-selfcontrol.py", line 23, in load_config
    config.update(json.load(cfg))
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting : delimiter: line 18 column 9 (char 469)

Multiple blacklists?

I'd like to have:

  • 9:00am-5:00pm - Blacklist 1
  • 8:00pm-10:00pm - Blacklist 2

Is there a way to do that?

Not always activating

Not sure if this is a selfcontrol bug, or an auto-selfcontrol bug so I'm posting it in both repos. Auto-self control often won't automatically activate on the schedule I have set up (single blacklist). When the sites on my blacklist are not being blocked in the scheduled time and I go to open the selfcontrol app it reports that it's stuck and requires me to stop it manually. Except, that it's not really stuck since all of the websites in my blacklist are accessible in firefox.

After this all happens, if I enter 'auto-selfcontrol activate' during a time scheduled for blocking, selfcontrol starts right up and is blocking my blacklist.

I'm running macOS 10.15.5, and I recently got the updated version of both selfcontrol (3.0.1) and auto-selfcontrol

Does SelfControl have to be running before the script is ran?

EDIT: Perhaps it means that the SelfControl app needs to be open, but not necessarily running (ie. blocking domains)? I tried that and got different console output, although it still isn't blocking anything.

~/auto-selfcontrol-master » sudo python auto-selfcontrol.py
Password:
> Start installation of Auto-SelfControl
> Removed previous installation files
> Installed

> Active schedule found for SelfControl!
> Start SelfControl (this could take a few minutes)

2016-12-07 22:36:47.871 org.eyebeam.SelfControl[22783:3920080] Using your own bundle identifier as an NSUserDefaults suite name does not make sense and will not work. Break on _NSUserDefaults_Log_Nonsensical_Suites to find this
2016-12-07 22:36:47.874 org.eyebeam.SelfControl[22783:3920080] ERROR: Not enough block information.
-203
> SelfControl was started.

~/auto-selfcontrol-master »

config.json (I also tried it with weekday omitted; and I also tried various start/end times)

{
    "username": "adamzerner",
    "selfcontrol-path": "/Applications/SelfControl.app",
    "host-blacklist": [
      "twitter.com",
      "reddit.com"
    ],
    "block-schedules":[
      {
        "weekday": 3,
        "start-hour": 11,
        "start-minute": 1,
        "end-hour": 11,
        "end-minute": 5
      }
    ]
}

console output

~/auto-selfcontrol-master » sudo python auto-selfcontrol.py
> Start installation of Auto-SelfControl
> Removed previous installation files
> Installed

~/auto-selfcontrol-master »

I have the Self Control app installed, and have been using it for months. It is located at /Applications/SelfControl.app.

/Applications » ls
App Store.app            Install macOS Sierra.app SelfControl.app

First I tried all of this without having started SelfControl. Then I saw it mentioned in the README that SelfControl should be running before the script is run ("Start SelfControl and backup your blacklist as it might get overridden by Auto-SelfControl."). So I tried running SelfControl with only google.com in the blacklist for 15 minutes, and then running the command to block twitter.com and reddit.com for two minutes. It didn't work. google.com was blocked, but the others were not.

Then, while SelfControl was running, I changed the config file to start after the current SelfControl ends, and ran the script. That ended up working.

Can you elaborate on what exactly needs to happen for it to work?

Opening the selfControl app seems to cancel a running scheduled block

I'm wondering if this is a known limitation. Normally when opening the selfControl app while a block is running you'll see the time left in the block. When I open the app during a scheduled block by auto-selfcontrol, I'm prompted with the UI that shows when there is no block running and the scheduled block is cancelled. Auto-selfcontrol seems to work fine otherwise.

And thanks for putting this up on github

Two bugs with the new update.

Bug 1:
Cannot run auto-selfcontrol when your current time is in the schedule. Lets say its weekday 3 and the time is 17:30, then this line in config.json would crash the program:

"weekday": 3,
			"start-hour": 17,
			"start-minute": 0,
			"end-hour": 9,
			"end-minute": 0

Bug 2:
Multiple blacklists as seen in #14 don't work anymore. The program doesn't crash but self control doesn't activate on schedule.

Btw. thanks for the program! It has helped me a lot.

Can I run multiple separate schedules?

I'd like to have one schedule for the workday which will be a blacklist, and then a separate schedule for late in the evening which will be a whitelist. I'm thinking about installing a second instance of auto-selfcontrol.

Will that work?

auto-selfcontrol will break with upcoming SelfControl release

Hey @andreasgrill, I’m the author of the SelfControl app itself. I’m about to release an update with a giant refactor that will hopefully make SelfControl less buggy, more tamper-proof, and way easier to update in the future. BUT, it will break auto-selfcontrol unless your tool is adjusted to match. I know many users love the auto-selfcontrol tool, so I wanted to give you a heads-up and see if we can coordinate on a fix.

Two big things that are changing:
1. We’re moving from a BlockStartedDate and BlockDuration to just a BlockEndDate that determines when the block will be over. This is
cleaner and makes it possible to cleanly extend a block without any hacks.
2. We’re no longer storing all settings in the user defaults. As an anti-tampering measure, some of the settings are "secured" with a hash and stored in a file with a pseudo-randomized name.

My proposed resolution is that I just make y’all a set of org.eyebeam.SelfControl command-line methods that do what you need, and you move auto-selfcontrol to use those instead of directly reading/writing from defaults. I think we could do that with these methods:

  1. org.eyebeam.SelfControl {userId} —version
    1. outputs the version string for the installed SelfControl command-line tool (note this may not be the same as the version of the installed SC app, since the command-line tool only gets copied over when a block is started)
    2. You'd use this method to decide whether to use the new behavior or fall back to the legacy behavior.
  2. org.eyebeam.SelfControl {userId} —is-running
    1. outputs YES if a SelfControl block is currently running, or NO otherwise
  3. org.eyebeam.SelfControl {userId} —install /path/to/saved/blocklist.selfcontrol
    1. blocklist.selfcontrol would have to be a saved blocklist in the SelfControl format (File —> Save Blacklist). That is very simple: Just a plist with two entries, HostBlacklist and BlockAsWhitelist. See this code to see exactly how we output those files: selfcontrol/AppController.m at b85462070b3f8e43a3d2831186f120b0ef079760 · SelfControlApp/selfcontrol · GitHub

The --version and --is-running methods are already implemented in the SC master branch; will work on the --install method taking blocklist files soon. Let me know if those work for you!. Thank you!

"host-blacklist": null doesn't pull from the existing blacklist

I've been experimenting with this and is seems if you leave "host-blacklist": null in the config.json it doesn't grab from the current blacklist in SelfControl. It seems to not block anything. When I add "host-blacklist": ["twitter.com", "facebook.com"] it works.

No JSON object could be decoded

Really struggling with this every time I change my schedule. I've read the other issue like this and even copy pasted the code in the previous thread and it still didn't work. Tried the JSON editor online and it looked like I'm good.

Any Ideas?

{
"username": "TheNewMe",
"selfcontrol-path": "/Applications/SelfControl.app",
"host-blacklist": [
"Facebook.com",
"www.quora.com"
],
"block-schedules": [
{
"weekday": 1,
"start-hour": 6,
"start-minute": 0,
"end-hour": 12,
"end-minute": 0
},
{
"weekday": 2,
"start-hour": 6,
"start-minute": 0,
"end-hour": 12,
"end-minute": 0
},
{
"weekday": 3,
"start-hour": 6,
"start-minute": 0,
"end-hour": 12,
"end-minute": 0
},
{
"weekday": 4,
"start-hour": 6,
"start-minute": 0,
"end-hour": 12,
"end-minute": 0
},
{
"weekday": 5,
"start-hour": 6,
"start-minute": 0,
"end-hour": 12,
"end-minute": 0
}
]
}

Couldn't find preference file on first run.

I got this in the terminal on first run

$ python auto-selfcontrol.py
Password:
/Library/LaunchDaemons/com.parrot-bytes.auto-selfcontrol.plist: Could not find specified service
> Installed

Next time I ran it I didn't see it.

start after install but nothing happens to the hosts file. IOS V. 10.13.2

First up: thanks for your awesome work! But there seems to be a problem...

I did everything as described in the README.
Self Control is running when I start and the timer is 'ticking' down like it should.
But the hosts file does not get written/changed although I have put some sites in the hosts-blacklist.
Also every time no matter if Self control is running or not the function
check_if_running returns true.

Am I doing something wrong or is there an issue at the moment?

Times below just for testing:

{
    "username": "NilsBertram",
    "selfcontrol-path": "/users/NilsBertram/Applications/SelfControl.app",
    "host-blacklist": [
        "twitter.com",
        "reddit.com",
        "google.de",
        "google.com"
    ],
    "block-schedules":[
        {
            "weekday": 1,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        },
        {
            "weekday": 2,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        },
        {
            "weekday": 3,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        },
        {
            "weekday": 4,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        },
        {
            "weekday": 5,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        },
        {
            "weekday": 6,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        },
        {
            "weekday": 7,
            "start-hour": 0,
            "start-minute": 0,
            "end-hour": 23,
            "end-minute": 59
        }
    ]
}

"No JSON object could be decoded" in terminal

Hi I did follow how to set it up but when im at the stage "Execute sudo python auto-selfcontrol.py to install Auto-SelfControl with the block-schedule defined in config.json."

it says

The json config file /Users/Jonte/Desktop/JONTE/autoselfcontrol/auto-selfcontrol-master/config.json is not correctly formatted.The following exception was raised:
No JSON object could be decoded

"{
"username": ”Jonte”,
"selfcontrol-path": "/Applications/SelfControl.app",
"host-blacklist": [
"reddit.com",
"youtube.com"
],
"block-schedules":[
{
"start-hour": 8,
"start-minute": 0,
"end-hour": 8,
"end-minute": 10,
"block-as-whitelist":true
}
]
}"

Thank you.

Where do we run auto-selfcontrol activate?

I tried running auto-selfcontrol activate and python auto-selfcontrol activate and python setup.py and python auto-selfcontrol.py, but my config isn't working.

Can you please specify in the docs where we should run auto-selfcontrol activate

Thanks!

No JSON object could be decoded

ERROR:
The json config file /Applications/auto-selfcontrol-master/config.json is not correctly formatted.The following exception was raised: No JSON object could be decoded

this is the code , just copied and pasted, as per the example, as a test:

{
"username": “stan”,
  "selfcontrol-path": "/Applications/SelfControl.app",
"host-blacklist": [
    "twitter.com",
    "reddit.com"
],
"block-schedules":[
    {
        "weekday": 1,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    },
    {
        "weekday": 2,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    },
    {
        "weekday": 3,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    },
    {
        "weekday": 4,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    },
    {
        "weekday": 5,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    },
    {
        "weekday": 6,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    },
    {
        "weekday": 7,
        "start-hour": 8,
        "start-minute": 0,
        "end-hour": 17,
        "end-minute": 0
    }
]

}

How to make block go between days with no space between

So currently my blocklist is like the following. Between 23:59 and 0:00 there is one minute and that means I can quickly download a vpn, etc (don't worry about how I'm so fast or anything let's worry about the issure here). If I did Tuesday 0:00 that would be then 24 hours earlier.. so I just have to stay at Tuesday 23:59 and then restart at 0:00 for Wednesday

{
"weekday": 2,
"start-hour": 16,
"start-minute": 15,
"end-hour": 23,
"end-minute": 59
},
{
"weekday": 3,
"start-hour": 0,
"start-minute": 0,
"end-hour": 7,
"end-minute": 31
},

Different Blocklists for different schedules

Hi,

would it be possible to get a feature to specify which blacklist to use for a specific blocking period?
For example, I would like to block Netflix and Twitter from 0700 to 1700, but allow it afterwards, while I would like to block Twitter from 1800 to 2400, but keep Netflix available.

Would that be possible?

ImportError: No module named Foundation

When i run
User-MacBook-Pro:auto-selfcontrol-master user$ sudo python auto-selfcontrol.py

Traceback (most recent call last):
File "auto-selfcontrol.py", line 10, in
from Foundation import NSUserDefaults, CFPreferencesSetAppValue, CFPreferencesAppSynchronize, NSDate
ImportError: No module named Foundation

Error username

Hi,
the terminal gives me this error:
ERROR:
Username John Smith unknown. Please use your OSX username instead.

Do you know how to solve?

Need to restart computer for the block to occur the next day

Hi, so I set my schedule to be activated at 12:05 am to 11:59pm. When I run auto-selfcontrol activate, it runs for the whole day but is no longer active the next day. It is only active when when I restart my computer, which is expected behavior because the script is in LaunchDaemons. However, I cannot get it to block consecutive days...

FYI: I installed using homebrew and have the latest version of both SelfControl and auto-selfcontrol. Here is my config:

"block-schedules":[
	{
		"weekday": 1,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	},
	{
		"weekday": 2,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	},
	{
		"weekday": 3,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	},
	{
		"weekday": 4,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	},
	{
		"weekday": 5,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	},
	{
		"weekday": 6,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	},
	{
		"weekday": 7,
		"start-hour": 0,
		"start-minute": 5,
		"end-hour": 23,
		"end-minute": 59
	}
]

Can we do seconds in auto self control?

@slambert @andreasgrill

Hi all (again),

Was just curious if I could do the following

{
    "username": "MY_USERNAME",
    "selfcontrol-path": "/Applications/SelfControl.app",
    "host-blacklist": [
        "twitter.com",
        "reddit.com"
    ],
    "block-schedules":[
        {
            "weekday": 1,
            "start-hour": 9,
            "start-minute": 0,
           "start-second": 15,
            "end-hour": 17,
            "end-minute": 30,
            "end-second": 35
        },
    ]
}

Thank you!

Sorry this isn’t an “issue” in the normal sense, but wanted to thank you (and @sbibauw for their fork)—this scheduler has helped me a ton, since I can now “default” to sites I want to avoid being blocked and then open them up at certain windows.

y’all rock ❤️

How to reflect changes on config file?

Hi @andreasgrill , thanks for the awesome utility.
I got a few questions about how this works thou.

  1. It doesn't seem to pull from my default blacklist list? Does it only use the config file?
  2. If i change the blocked website list in the config file, when does it applies? i already did sudo python auto-selfcontrol.py, but still the blocked list doesn't change, does it need to wait until i restart? or when the next scheduled block of time? If so anyway to make it reflect straight away?

Cheers

Block timing issues with auto self control + Random site blocking even when not on blacklist

Firstly:
I have back to back blocks where 7pm to 0:30 I've got everything in my blacklist blocked.. then 0:30 to 0:40 only specific sites blocked from a specific blacklist (method here) then 0:40 to for example like 5am i've got everything blocked again, but sometimes it doesn't go from my my specific blacklist back to the block everything immediately and it takes like a random amount of time to 'flip the switch and start blocking'... the same goes with even non back to back blocks for example ok 3pm to 8pm i've got a block and i reach home at 4pm and well its not blocked although it should have started blocking from 3pm.. the computer is off from 2pm to 4pm so does it sometimes not block/start the app or something when the computer is off?

Also:
Sometime sites randomly will just be blocked even if not on blacklist and then suddenly later in the day they are accessible again (since they were never on the blacklist to begin with).. any idea why this happens?

Finally:
so I have this site (NOT blocked) called (i've made up the name but the domain structure is the same)
kais.ac.jp which i can easily access.. however similarily the site learningspaces.kais.ac.jp is blocked and i've checked about 3 times its not on my blocklist.. but still for some reason its blocked even if the site itself (kais.ac.jp) is not blocked. Any idea what to do here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.