Add an "Exclude" list

When I’m searching something on the web with incognito mode on, I probably don’t want aw to track this. I could just disable the watcher but auto exclude of some might be very useful.

6 Likes

Yes! Please implement a way to auto exclude incognito/private sessions in Firefox/Chrome/etc.

5 Likes

+1 request for this feature!

I use Firefox both for work and leisure, so firefox.exe is always the top entry on my application activity list. I want to be able to remove it from that list. I already categorise browser domains, as it’s personally more meaningful data.

1 Like

I have search the documentation but could not find how to exclude folder or program’s

+1 from me to. I’d like to exclude certain apps/websites/etc from tracking too.
Thanks!

I’m also looking for something like this, chrome.exe tends to cover my category sunburst, it would be great to exclude it from that so I can view the specific categories i.e. this time spent in Messenger, these websites are uncategorised etc. Something to exclude an application from this would be great if possible!

Yeah, for now my personal best effort is to make a category called “Exclude” that I can leave out of my filter views, but it’s certainly not an ideal workaround…

I am using this to track how many hours I have in games, for games that don’t have that built in. (cough cough minecraft) I don’t want it tracking how much I use firefox.

You can create a subcategory under chrome which will give details about which websites are used in a hierarchical manner.

+1 from me too.
Perhaps the current Categorization system could use an extension? Each rule could have an option to be “Hidden” that we can check and then system would not show them in summaries/etc?

+1. I would also like the ability to specify for some programs that they do not write the title to the history. For example, for OneNote it is not necessary and even harmful, because passwords, secret keys get into title and then in the file logs.

2 Likes

I learned the ActivityWatch schema, and we don’t have server side category data.
I create this feature request Server Side Category. It may potentially be used to serverside blocking of the events from AW-Watchers. Any sensitive information will never be stored. 1

I have AW on my Mac to logging the “loginwindow”. That’s the Mac login when I’m away from keyboard.
Although afk, it’s still counted in Uncategorized time. This creates a false report. I have to find and delete those “loginwindow” records

1 Like

i think API can be used for now, ive had success with this script,

import requests
from concurrent.futures import ThreadPoolExecutor

BUCKET = "aw-watcher-window_Titan"
POOL = ThreadPoolExecutor(max_workers=10)
CONTAINS = "Private"
events = requests.get(f'http://localhost:5600/api/0/buckets/{BUCKET}/events?limit=1000').json()


def delete(e):
    resp =  requests.delete(f'http://localhost:5600/api/0/buckets/{BUCKET}/events/{e["id"]}')
    if resp.status_code != 200:
        print("failed to delete event", e['data']['title'])
    else:
        print("deleted event", e['data']['title'])


for e in events:
    if "Private" in e['data']['title']:
        POOL.submit(delete, e)

code is prettymuch self explanatory just replace your bucket and pattern to delete unwanted events. tested for firefox private window.

2 Likes

Thank you @Nikhil_Swami!

I converted your Python code to Bun TypeScript code. I’m leaving it here in case it helps others too:

Save this as “index.ts”. Instructions in code:

/*
fetches/prints/deletes data from local activitywatch server based on your filter

based on: https://forum.activitywatch.net/t/add-an-exclude-list/345/17

Instructions:

1) You'll need Bun to run this script. See https://bun.sh

2) Open http://localhost:5600/#/buckets and copy your bucket names into BUCKETS array in code below.

You probably only have one bucket of interest.

I have two buckets because I also have the Chrome extensions installed.

My buckets are "aw-watcher-window_i7rtx3060" and "aw-watcher-web-chrome".

4) Edit SEARCH_EVENTS_CONTAINING with words you want to filter/delete.

5) Make sure DELETE_MATCHED_EVENTS = false on the first run to see what events are found first. You don't want to delete something important.

6) Execute this script with `bun run index.ts`

7) Once you are satisfied with the events it found to delete, set DELETE_MATCHED_EVENTS = true and run the script again.

*/

import { fetch } from 'bun';

const BUCKETS = ['aw-watcher-window_i7rtx3060', 'aw-watcher-web-chrome'];

const SEARCH_EVENTS_CONTAINING = ['twitter', 'twitch'];

const DELETE_MATCHED_EVENTS = false;

const main = async () => {

   for (const BUCKET of BUCKETS) {

      const events = (await (await fetch(`http://localhost:5600/api/0/buckets/${BUCKET}/events?limit=100000`)).json()) as any[];

      for (const event of events) {

         // Default Windows AW data is in this format:

         // {"id": 14567, "timestamp": "2024-09-26T11:15:51.771000+00:00", "duration": 4.051, "data": {"app": "chrome.exe", "title": "TypeScript | Bun Docs - Google Chrome"}}

         // Chrome extension data is in this format:

         // {"id": 24471, "timestamp": "2024-09-28T12:18:12.587000+00:00", "duration": 0.698, "data": {"url": "https://developer.mozilla.org/en-US/docs/Web/API/Request", "title": "Request - Web APIs | MDN", "audible": false, "incognito": false, "tabCount": 21}}

         const searchString = ((event.data.url || '') + (event.data.title || '')).toLowerCase();

         if (SEARCH_EVENTS_CONTAINING.some((search) => searchString.includes(search))) {

            console.log('Found:', searchString);

            if (DELETE_MATCHED_EVENTS) {

               // await fetch(`http://localhost:5600/api/0/buckets/${BUCKET}/events/${event.id}`, { method: 'DELETE' });

               console.log('Deleted:', searchString, ' with id ', event.id);

            }

         }

      }

      console.log('Done searching total events:', events.length, 'in bucket:', BUCKET);

   }

};

main().catch((err) => console.error('Error:', err));
1 Like

Would really like an exclude feature. A few processes that do not really need to be logged.

1 Like

I need to exclude loginwindow on MacOS… This is the screen that appears when the Mac is locked, it’s goofy to record time spent on a Lock Screen.

I can’t seem to get this working properly.
The bun script executes and lists out all of the filtered events. Finds plenty, even says Deleted: event underneath. But nothing gets deleted - if I execute it again right after it presents the same found events, saying deleted etc.
Any ideas what could cause this ?

Sorry friend. You must uncomment this line. I forgot to uncomment it:

// await fetch(`http://localhost:5600/api/0/buckets/${BUCKET}/events/${event.id}`, { method: 'DELETE' });

I’ll try to edit the original message. edit: it’s not letting me edit. Oh well.

Hope it works for you.

1 Like

You’re a legend mate ! thank you :grinning: