Log the path of open files for categorization

I think it would be a useful feature to log the full path of a file that a window has open. This would be platform dependent. E.g., On MacOS I can see when I find Skim.app has pid 4031 that it has a number of files open,
> lsof -p 4031 | grep pdf
Skim 4031 alexc txt REG 1,4 2269846 8627682846 /Users/alexc/Downloads/Andrew W. Appel - Modern Compiler Implementation in Java, 2Ed (2002).pdf
Skim 4031 alexc txt REG 1,4 15571908 8594585922 /Users/alexc/Documents/Computer Science/AI/Artificial-Intelligence-A-Modern-Approach.pdf

It might be a bit hard to match which file is open in which window, but at least with Skim the window title contains the file name (without path), so that would be relatively simple to match.
I expect this would be a complicated task, but very useful so you can have a category rule like “PATH /Users/alexc/Documents/Computer Science/” so any window working on a file with that path prefix would be categorized as e.g. “computer science”.

Doing lsof on firefox for me gives a list of 470 files which are 13kb long, saving 51kb for each time you switch windows would take up a lot of disk space.
If I remove sockets from lsof and only look at regular files it becomes 320 files which is 10kb long which is still way too muck data.
If I only look at files in my home directory it’s 44 files and 4kb, significantly less but still quite a lot considering that a normal window event today is usually significantly less than 200 bytes.

Firefox is an application I obviously use a lot so this would fill up by SSD in no time even if it was just logging files in my home directory.
Most applications also put the name of the file it’s currently working on in the window title (PDF readers, microsoft word, text editors etc.) so filtering by files an application has open is probably an edge case.

This feature could still be added as an feature to toggle on manually, but I don’t think it’s a good idea to have such an feature enabled by default.

2 Likes

Can’t you just filter that list to get the open documents?