iloveitaly / hyper-focus

Block hosts, apps, specific urls (with query string vars!), launch scripts on wake, and generally optimize your productivity and focus
MIT License
50 stars 2 forks source link

Add allowlist functionality and regex matching #4

Closed dgfl-gh closed 9 months ago

dgfl-gh commented 1 year ago

Right now, this is only a draft with a really quick and dirty implementation because I don't really know Swift (but wanted to use the software because after trying the other options, I agree with your conclusions).

I've made it so that the patterns in all lists are matched with regex rather than simple substring matching, and I've added some "allow lists" that "undo" the action of the block list. That is, if a pattern is matched by both block list and allow list the allow list will take precedence and the item should not be blocked.

The intended use case (for me, at least), is to have a global (or almost global) block pattern set, and then selectively allow a few domains.

dgfl-gh commented 1 year ago
  • Could you write a little readme entry about the use case for allowlists? I'm still trying to understand the "why" behind this.

Sure, in which section? To be honest, the use case is pretty simple. I have a small website that I need to use while I work, and 90% of the time being able to visit every other website is just a source of distractions. So I block everything but the websites I know I will need, and I need an allow list for that.

  • Could you pull the regex matching into a separate PR?

Sure, I'll try to do that in the following days.

iloveitaly commented 1 year ago

Sure, in which section? Blocking section should work great.

A quick blurb about how this works with the block_* config options would be great too.

So I block everything but the websites I know I will need, and I need an allow list for that.

Ah, interesting! This makes sense. Only requirement from my end would be making these optional, not required in the config schema.

iloveitaly commented 9 months ago

Sorry it took an age for me to merge this in! Just added your contribution and tweaked it a bit. Curious your feedback if you get a chance to try it out!