Subtle thing going on with NotebookDirectory[]
—if the notebook exists at all as a file which was ever saved, then NotebookDirectory[]
will return the save location, but it doesn't have anything to say about the "current state" of the notebook vs. its "saved state".
You can get something kind of related via NotebookInformation[]
—namely, you can get a "saved" time and a "modified in memory" time. I thought that maybe taking their difference could be instructive, but I think that just running the code itself counts as "modified in memory", so you wind up getting the time in seconds since your last save with this:
Subtract @@
Lookup[Association[NotebookInformation[]], {"MemoryModificationTime",
"FileModificationTime"}]
As for the greyed out icon, maybe I can tell you another new thing re: macOS—the reason that that icon gets greyed out is that it's a fully-functional "link" to the file in question! When you have unsaved changes, the saved file and the "working file" no longer match up, so it greys out to indicate that the "link" is no longer active. But if you've got an up-to-date file open, you can drag that icon around and it will act like the file itself—that is, you could drag it onto this page to embed it in a post, or drag it over to an email to attach it, and so on.
In any case, I'm glad you're having fun with the code!
EDIT: However, if you're in another notebook, you can point to the Notebook of Interest as follows and this will work:
Subtract @@
Lookup[Association[
NotebookInformation[
NotebookOpen[
"path/to/NotebookOfInterest.nb"]]], {"MemoryModificationTime", "FileModificationTime"}]