Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

citizenzen

macrumors 68000
Original poster
Mar 22, 2010
1,543
11,787
I'm a graphic designer and I've been looking for a good way to track time, especially for users who can't remember to click Start and Stop buttons on time clocks. I found a website, rescuetime, that comes close to accomplishing the task, but still comes up a little short.

RescueTime records the active window on your finder and the time spent on it. It generates a time log and doesn't require any input from the user. But it doesn't record the filename. For instance, it will say a Photoshop file was open for 5 minutes when I need to know that foo.psd was open for 5 minutes.

How hard would it be to create a program that records the time a window is active and the filename?
 
I posted this question in the Apple Discussions (programming threads) and the same thing happened: I got a bunch of views... and absolutely no responses.

Am I asking for the impossible?

How come a website can do it?

BTW, I talked to a sales guy at the site and he said they would have the capability of gathering all file names (it seemed to be an Adobe® issue) within three months. But I just chalked that up to him being a sales guy.
 
The difficulty depends on the programs used and whether they will report which files are open. It is probably possible to track this without the cooperation of the program as the OS has a list of all file handles. Mapping the file handles back to program processes would be the next step and then mapping the processes back to the program is the last step.

Many programs can keep multiple files open, so then you need for them to report which open file is active.
 
It is probably possible to track this without the cooperation of the program as the OS has a list of all file handles. Mapping the file handles back to program processes would be the next step and then mapping the processes back to the program is the last step.

Thank you. That will give me a place to begin.

Do you think a graphic designer with some Javascript and PHP experience could pull something like this off using Apple's Developers Tools? Or is that as bad of an idea as having a programmer layout a brochure or design a logo?
 
Thank you. That will give me a place to begin.

Do you think a graphic designer with some Javascript and PHP experience could pull something like this off using Apple's Developers Tools? Or is that as bad of an idea as having a programmer layout a brochure or design a logo?

I am not on Mac OS right now, but the "lsof" program will list open files in human-readable form. I tried emacs (a text editor) on my Linux system and there are a lot of other files associated with just that single process. In particular, the "emacs" process has opened up a lot of library files in addition to the working directory. It didn't list the file I opened, but that could be because emacs opens the file long enough to read into memory and then closes that file handle. So there could be problems with this approach.

Anyway, I would guess the skills/knowledge required to do this is:
unix processes, file handles, text pattern matching, and data structures in your language of choice.

It wouldn't surprise me if you have to use a system calls via a compilable language (obj-c) instead of trying to parse output from existing system utilities if those utilities don't provide enough info.
 
As someone said earlier, the command 'lsof' is going to help you out. What you need to do is run that command with the -p parameter and supply the PID of the process you are inquiring about.

You will probably have to discover child process IDs along the way but ps or pstree should be able to give you that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.