jy-gh / RecentFiles

An Alfred workflow--and a command line utility--to easily find recently modified files.
MIT License
10 stars 0 forks source link

Optionally watch for recently opened? #1

Closed NeighNeighNeigh closed 2 years ago

NeighNeighNeigh commented 2 years ago

Firstly love this workflow, I stumbled upon it in the Alfred gallery post. nice work :)

So Im just wondering if it would be possible to optionally watch for last opened as well as last saved? This would make RecentFiles able to switch between currently open or recently open documents, even if they haven't been saved since opening.

Cheers :)

jy-gh commented 2 years ago

Thank you! That is very much appreciated.

As for adding support for last opened time, well, that's more difficult than it would seem initially. Under the hood, the Recent Files workflow uses the fd command. fd doesn't support checking against the last access time of a file, only the modification time.

The find command does have a flag, -atime, that can be used to find files that are within a given time period, but find is slower than fd and then one loses the ignore files functionality.

Now, it occurred to me that in macOS one can create a Smart Folder that shows both recently modified files and recently opened files, and that almost does what you're talking about. However, it comes with two significant problems. The first problem is that I don't know that there's a way to access a Smart Folder programmatically or via the command line, which would be necessary in order to get results from the Smart Folder into an Alfred workflow. The second problem--and you'll see it if you create a Smart folder like this--is that it will return a ton of results that simply aren't useful, with few options to trim down the results into something manageable. (And the results can grow even if you're not doing much in the way of using your computer, as various background processes can create/modify files that then show up in the Smart Folder.)

Other than adding this to fd--and that's likely beyond my ability--I don't know of a good solution that doesn't involve a trade-off.

Thanks again for the compliment!

NeighNeighNeigh commented 2 years ago

Ah okay I see, well thank you very much for taking the time to investigate :) and thanks again for the workflow