Hacker News new | ask | show | jobs
by bm98 2670 days ago
Tracking time is part and parcel of being a consultant, at least if you have multiple clients and overlapping work. After doing it for 15+ years, I've tried it all - everything from the spreadsheet, to the apps, to forgetting and having to go back and reconstruct.

I read this article and I think it's missing the point about what's so hard about time tracking.

What's hard is: Implementing the trigger on the context switch.

You're working on one thing, something happens and you make a context switch to something else - and in order to track your time, you need a trigger to fire to prompt you to record the switch. It doesn't matter if it's in a spreadsheet or an app or on a piece of paper - I find that my brain doesn't fire that trigger very reliably. Especially if I'm busy.

If someone can solve that problem with a fancy app, I'd be impressed!

I've said it in another thread [1]: I want a robot that watches me and quietly makes intelligent decisions about what I'm really doing, and tracks that.

[1] https://news.ycombinator.com/item?id=15790918

11 comments

I have this in a cron:

  * 08-23 * * * ~/.local/bin/with-i3 '~/.local/bin/record-active-window'
this is record-active-window:

  # set LOGFILE to whatever place you want to record things.

  echo "DATE = $(date +%s 2>&1)" >> $LOGFILE
  echo "IDLE = $(xprintidle)" >> $LOGFILE
  xprop -id $(xprop -root  _NET_ACTIVE_WINDOW | sed 's/.*# //') WM_CLASS WM_NAME 2>&1 >> $LOGFILE
this is with-i3

  #!/bin/bash

  source <(cat /proc/`ps -e | grep ' i3$' | awk '{print $1}'`/environ  | sed -r -e 's/([^\x00]*)\x00/export \1\n/g')
  bash -c "$*"
I was too lazy to figure out what env vars were missing from the cron (probably dbus socket) so i copied them all from the i3 process above

That plus the habit to lock the screen while I'm away from it works fairly reliable.

edit: you also have the idle time in case you want to ignore result where you've been idle for way too long (forgot to lock screen)

edit2: a sample log entry (idle is in miliseconds, date is unix timestamp in seconds)

  DATE = 1550608681
  IDLE = 2456
  WM_CLASS(STRING) = "google-chrome", "Google-chrome"
  WM_NAME(UTF8_STRING) = "Edit | Hacker News - Google Chrome"
If only Slack changed the window title when I change chats, I could also track how much time I spend talking where :) The web version does it though, so I might stop using the electron app...
Have you come across arbtt? It's a script that pretty much does exactly the same thing, but comes with a few extras for categorization and analysis.
I don't like arbtt because it has an undocumented binary log format making it unnecessarily difficult to build tools on top of it. Its documentation in general is also poorly written.

This is not perfect either, but its just a little extra work to convert it to JSON and put it in elasticsearch to use kibana on it.

I did something similar and found it to be useless for how I work. I even wrote a second tool in Rust that uses the WINAPI (throwback to 1998 when I last used it). Sure, numbers might be 50% correct, but maybe they're not.

Say I'm supposed to write some code, so the IDE should be the front window. But I get carried away trying to test an edge case, so I spend 4h in a shell doing stuff that's 100% related, but not in the IDE. Not really a contrived example. Or spending 3h in a browser researching something and reading docs and forum posts about $software when I was supposed to write a one liner fix.

TLDR: Didn't work, gave up with it.

You can't just automatically use the results - at the end I group them by window title and look at things that are > 5m

Not perfect but decent.

Of course I did some post-processing, didn't really help - for me - as I wrote.

But just take the category "browser usage" as an example.

Semi-relatedly, one reason I hate web apps for "persistent" things that should be standalone, e.g. stuff like Slack or E-Mail. Not only does it not fit my mental model with alt-tabbing, it also lumps this uselessly together like "GUI usage vs CLI", so broad is "browser".

Window titles are recorded by this script. I wonder if you noticed this? You could have pretty decent filters with those, e.g. you can get a result for "time spent reading comments and writing on hackernews". If I use slack in the browser, i can even get the time i spent talking to different people / channels.
Couldn't agree more, I also can't reliably track the context switches when contracting. The only thing that works for me is to let my app give me a reminder every few minutes. I used Toggl and set it to 15 minutes. It's annoying most of the time, but it also saves my butt routinely, and is the only thing so far that's worked reliably.
I do exactly the same thing, but when you think about it, isn't this just a pomodoro? You work for 25 minutes. An alarm rings. You take a 5 minute "break". In reality, in that "break" I quickly write down what I accomplished in the last 25 minutes and update my TODO. I also look at my DONE tasks in my TODO list and think about what I was doing and why. I've often found this kind of retrospective to be valuable. I'll notice that there is a better way to accomplish what I'm doing, etc, etc.

As crazy as it sounds, I've even experimented with 5 minute "pomodoros" using this technique - 5 minutes on and 1 minute reflecting. What can you do in only 5 minutes? When I first started it was hard to think in those terms, but as I got better at it, I realised that almost everything I do takes less than 5 minutes. If it takes more, then it's an indication that I need to rethink my approach.

For example, if I'm reading code, it makes sense that it would take more than 5 minutes, so I'll make a goal -- find out how X works. If I'm not finished in 5 minutes, in my 1 minute retrospective I think, "Am I approaching this task in the right way? Is there a better approach?" If no, then the next 5 minutes will be the same as the first. However, I often find that having that break snaps me out of doing unnecessary things.

I can't do the 5 minute thing every day (it is exhausting). I'm dramatically more productive with it, though (surprisingly so). It's made me realise that these kind of enforced reflection periods are really valuable. While you are reflecting, it's easy to write down what you just did, so it's kind of 2 birds with 1 stone.

I'd have to think about the pomodoro thing. Maybe, but I developed an almost unconscious reflex to hit the 'ok' button on the timer to make it go away. I would try very hard to not have it make me think about anything, just confirm which task I was in the middle of. The main thing it caught was when I hadn't re-started a timer after finishing something and stopping it, and when I switched tasks without telling the timer. I'd take a second to fix it, but not stop to reflect, nor break down my tasks. After the first reminder, I'd try to ignore them again.
I found the context switch trigger too hard a problem to solve. The real problem for me was that I found any app that tried to watch me work just too creepy. So then any simple app required lots of manual effort.

I built myself a solution that means I can add events to a calendar that describe my day. Different calendars for different clients and different event titles for each project.

This worked well for me and now I’m trying to build it out and sell it. If you’re interested it’s here: billabl.co. I’ll warn you though, it’s early days and likely to break (although I’ve been using it for years).

Minor bug, but it looks like all your call-to-actions on the features page are too large. (FF on Pixel 1)
Ha! Cheers! I’ve not checked on my phone for a while, that’s definately not right.
The Timing app for macOS (no affiliation) does essentially that, and then displays in a timeline of sorts. When one really needs to track time spent on tasks/projects, a quick after-the-fact look at the timeline makes it easy to spot blocks of "downright coding", "wondering how to do something", etc.

The UI is great for that as well - identify a block that is made up of several 1-minute back-and-forths between browser and IDE, drag across that, and enter task, for example.

That sounds like a great app, thanks for the tip
100% agree with the trigger being the hard part, and with wanting the observer robot. I know there are partial solutions (RescueTime is a big one) which watch your text editor, or watch your web browser, or suck in meeting data from your calendar, but I've never really been that happy with them.

The further complicating wrinkle for me personally is that I work at a robotics company, so I spend a bunch of time at ssh terminals to remote machines (robots, shared VMs, etc) where it is neither practical nor desirable to install vim plugins hooked up to my personal time tracking setup.

So I'd love for the observer to be able to be able to also watch my remote shell sessions and record things like which file paths I'm editing and commands I'm invoking, from which I could fairly easily construct rules about which general problem area I'm working in.

If you have RescueTime window titles / details enabled for your terminal app, and have configured your terminal app (if it supports it) to promote active shell command to window title, you get this details, regardless of where you are ssh'd to. Works for me at least on macOS + iTerm2.
I feel like it'd be nice to have a foot switch or hardware you can plug in to USB with maybe 5 buttons and an accompanying app. Maybe you can tap these buttons to switch the counter and press the active button again to pause the current counter.

I still feel like some type of foot switch would be better though.

I just gave up on that and use an app that makes it super easy to go back and reconstruct [1]; either a few minutes after the context switch (I just type "-14 Project 2" and it changes the task 14 minutes in the past), or later through a nifty graphical interface.

The provided reports are also great, but if I need anything crazy, I can easily extract the data from the SQLite database.

It's been working for me for many years now.

[1] https://github.com/projecthamster/hamster

I’ve stopped doing it reactively and instead take 30 mins at the start of my day to roughly plans out when I’ll be doing things in my calendar.

I get a notification 15 mins before a task change occurs so I can decide either to continue because I’m on a role (often not the case, actually just flailing at a bug) or move on.

If plans change I can usually retrofit my day as the calendar reminds me of the general structure.

It’s worked significantly better for me than reactively tracking my time unless the task length is small e.g. sub 30 mins (something like marking a single students work).

I use the Pomodoro Technique and Rescue Time.

Pomodoro forces a context change, every half an hour. This way I don’t end up yak shaving for half a day when all I needed to do was realise that this solution would require yak hair, go find a different solution.

Rescue Time helps me figure out what I was doing as a kind of forensic tool. There’s heaps of prodding and follow up available in the premium package (apparently), but for me just knowing that I will need to explain to myself why I spent three hours on HN and Reddit today helps me stay away. Mostly.

I use different desktops for different tasks/clients and have a script that keeps track of which one I'm on.

Using the desktops is an extra bit of information I can use to give context to the robot to help with tracking.

So a manager!