Block/limit access to sites/apps after some amount of usage

Topic moved here from the issue tracker:

Intent seems to do this in a more gentle and helpful way (and on a per-site basis), as opposed to StayFocusd’s all-out blocking of all distracting sites once the time is out:

https://browsewithintent.com

1 Like

LeechBlock is another pretty decent one (it can “delay” pages).

1 Like

For linux users /etc/hosts might be a good solution.
Although that would be very hairy from a security stand point with having an extra user for activity-watch being the best solution i can come up with.

Today someone reached out to me and offered a $250 bounty for building a cross-browser web extension that blocks websites similarly to LeechBlock but that uses ActivityWatch as the backend for time tracking.

I looked at the LeechBlock source code and found the function that checks if a site should be blocked or not: https://github.com/proginosko/LeechBlockNG/blob/master/background.js#L328

It shouldn’t be too hard to modify it to use ActivityWatch as a backend, and I like the idea of building on already solid code as is the case with LeechBlock. The code is also licensed under the same terms as ActivityWatch, MPL2, which is a plus!

In other news, I’ve started using TimeLimit for blocking/limiting apps on my phone, which I’ve been happy with!

He replied:

If you could make Leechblock fork that

  1. syncs along all devices (so I cannot run from one browser to another)
  2. keeps all the settings on the server of AW
    then I’m satisfied with that solution.
  3. you are sure the license is compatible

A natural continuation (for me) would be to actually cut myself off via firewall on my router :).
It would be also great if filters were able to watch not only domains but apps as well. Killing (or muting) steam after the limit would be great.

So yeah, offer stands. I am happy to pay half in advance, as soon as we agree on roadmap.

  1. Is technically impossible if you include browsers that do not support extensions (such as Chrome on Android/iOS).
  2. That might be bit tricky, since ActivityWatch does not currently have server-side settings (but we’re working on it, since it’s needed for other features that are in development)
  3. Yes, we’re using the same license (MPL2.0)

Blocking of non-web apps would have to be a separate thing, and is not something I’m personally interested in (on desktop, phone apps is a different story, but as mentioned in the previous post I’m happy using TimeLimit for that).

1 Like

Well by “all devices” I meant all browsers that support extensions. Or more widely: all clients compatible with the protocol you define (so killing apps, adjusting firewall I would write myself).

I’ve started working on a desktop extension that uses activity watch to block apps after reaching a time limit. To block apps, I added ~/.config/activitywatch/share to the front of the XDG_DATA_DIRS and basically overwrote the original desktop files by placing dummy files in this folder. Does this seem like a good approach?

I’m not sure I completely understand. XDG_DATA_DIRS only contains data which applications uses, so if you replace those with dummys you would possibly crash the program you are trying to start? It’s possible also that programs don’t use anything inside XDG_DATA_DIRS and they would then not be blocked at all.

I haven’t really thought this through, but if I would have tried something similar my first attempt would probably be to see what the current focused window is according to the aw-watcher-window bucket and if the current app which is focused has reached some limit I would’ve created a pop-up dialog telling you that the app is blocked with the options to either kill the application (with a SIGTERM) or to postpone the reminder for X amounts of minutes.

Even just a notification/alert after you’ve crossed a certain threshold with a site would be really nice to have - for example, send a notification once you’ve been on twitter.com for over 45 minutes, then every 15 minutes after that. This could probably be made as an external thing that uses the API but it’d be a really useful thing to have built-in too.

Indeed, a first step would be to build such a notifying “time nagger” as an extension that uses the ActivityWatch API. If that works well we’d be interested in making it a built-in :slight_smile:

There are a few similar feature requests to this:

I have tried tons of these types of plugins, and the best I found is called Morphine (below). Unlike the others, it let’s you earn procrastination time as you don’t procrastinate. This works much better so that the user appreciates the balance between work and play, rather than just playing and ultimately disabling the “procrastination blocker” when it gets in their way. https://github.com/tkazec/morphine

On the Android side I’d highly recommend checking out Lock Me Out (https://play.google.com/store/apps/details?id=com.teqtic.lockmeout&hl=en_US&gl=US)

I would highly model the functionality rather than just a basic blacklist/whitelist.

1 Like