I’ve just become a father — which is awesome! And I work for a great company (Mantel Group / DigIO) which has gone above and beyond to support our new family. So what does this have to do with time-tracking?
Who loves time-tracking? Not me.
DigIO is a leading IT consultancy in Australia, and I need to track the time I spend on different projects and activities. But here’s the thing:
I find time-tracking INCREDIBLY booooooring (don’t tell my boss).
Consequently, I often find myself estimating how much time I spent on projects, rather than diligently recording how I’ve spent every minute of the day. Now, if you’re an accountant who happens to be reading this piece, you probably don’t understand why I don’t enjoy recording how I’ve spent every minute of the day. For everyone else, you will understand that recording everything manually is a chore.
The thought occurred to me while working out-of-the-office on paternal leave, “Why not automatically track your time?” So, using the fractions-of-spare-time I’ve had, I’ve put together a simple Node program to do just that…
active-win-log is a program records which window is in the foreground of your computer-desktop every 5 seconds. Then, when you want to know what your usage has been over the last few days, you can get a lovely report showing the hours:minutes:seconds of usage, grouped by day, program and window/tab:
Now I don’t have to estimate how long I’ve been programming, or determine how much browser-time was for work (and how much was for “not-work”).
Here’s what the program does not do:
- It doesn’t input data into your time-tracking tool. That would be awesome, but there’s a bazillion time-tracking tools out there and I have no time to support them all. Sorry (not sorry).
- It doesn’t track time away from your computer. That would require a drone or a network of cameras to watch you continuously, and determine whether the activity you are performing is considered “work” or not. Maybe the AI team at Eliiza could look into that…
- It cannot determine whether you are actually using a program, or have simply gone to the toilet while the program is active.
In summary, the tool can be used to give you a reasonable estimate of the time spent using each application, but it’s not gospel-truth.
How it works
Once installed, the program can be started by typing
awl in your terminal window. Now, normally when you start a terminal program it keeps running until it finishes it’s task. But if the task is, “monitor application windows FOREVER”, you would be forgiven for thinking that once you start
active-win-log, it will keep running in that terminal window and never allow you to type another command until you kill the process.
But there is another type-of-program in computer science called a daemon…
…which can offer a much better user experience. A daemon is a kind of computer program which runs in the background rather than requiring interaction with the computer-user.
active-win-log is written as a daemon, but it also allows you to interact with it as-though it were an ordinary program too. Which is kind of neat!
This was my first time writing a daemon program. If you are interested, you can take a look at the source code. You will probably find a bunch of things that could be improved — pull requests are always welcome (just follow the guidelines in
CONTRIBUTING.md). Bear in mind that I was sleep-deprived and trying to look after a crying baby while writing it. I took inspiration from laravel-logwatch which uses the same Node daemon library,
daemonize-process. The project also uses the
active-win module by Sindre Sorhus to detect the active window.