Skip to content

Instantly share code, notes, and snippets.

@dufferzafar
Last active March 15, 2023 00:19
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dufferzafar/1b5861c8c67be4cfc685726686836ca5 to your computer and use it in GitHub Desktop.
Save dufferzafar/1b5861c8c67be4cfc685726686836ca5 to your computer and use it in GitHub Desktop.
Design of an open source, cross platform, time tracking application.

Time Tracker

Build a Manic Time alternative.

The application would be in two parts:

  • a tracker agent that dumps data into some backend
    • should be dumb and not do much processing of the data
  • a reporting dashboard which will show various timelines, statistics etc.

Features

  • Completely Open Source

Multiple Datastores

  • Stay backend agnostic

  • Application can be built using something like SQLite

    • But the design should be generic enough to support any thing (JSONs, MySQL etc.)
  • This lets the user stay in control of whether data goes over the wire to some remote connectordb instance or stays locally in plain text files.

  • Export data as CSV, Excel etc.?

Not just active Windows

  • Collect other metrics from the system

  • Internet usage

    • For all interfaces?
  • Keyboard activity

  • Mouse activity

Setup

  • Should be straight-forward
    • pip install time-tracker
    • a shell script, if dependencies are needed etc.
    • might not be easy on Windows

Platforms

Linux

  • Try to be as Distro/DE agnostic as possible

  • View issues on Thyme to see what stuff can go wrong

  • External tools will do the heavy lifting

    • xdpyinfo
    • xwininfo
    • xprop
    • xdotool
    • wmctrl
  • If using Python, try to find pure python ways of doing the things

    • as it'll be faster than executing processes
      • do a performance test for this

macOS

  • Applescripts can do a lot of the heavy lifting

Windows

  • Windows API will make things quite easy
    • Manic Time is a proof of what all can happen

Prior Art

A list of tools (opensource & otherwise) that already exist, what they do, and what we can steal from them.

  • Written in Golang

  • New kid in town, so not mature enough

  • Has decent cross-platform support

  • Simple but neat UI

    • Made with Google Charts
  • Stores data in plain JSON files

  • Written in Python

  • Not actively developed (last commits in 2015)

  • macOS: Pretty legit looking support using PyObjC

  • Windows: pyHook, pythoncom

  • Linux: Pure Python XLib

  • Written in Python by Karpathy

  • Tailored to Ubuntu/macOS

  • Feels pretty hacky

    • Bunch of shell scripts etc.
  • Takes screenshots too

  • Linux: xdotool, wmctrl etc.

  • macOS: Custom application that is called by shell scripts

  • Windows: No support yet

  • Written in Python

  • Nice, clean code

  • macOS: No support yet

  • Windows: PyQt

  • Linux: Pure Python XLib

  • Too coupled with connectordb as a backend

Manic Time

  • Stores data in a .sdf databse
    • Schema can be stolen from

Rescue Time

  • Find what's special.

Waka Time

  • Time Tracker, but for Programming Editors only

  • Find out if there's anything special to what they do

    • something that can't be done via Title grabbing & some regex-fu

Reports Dashboard

Read and aggregate data from the datastore and display in the UI.

Use latest web technologies for building the dashboard:

  • React
  • d3.js charts
  • Material UI etc.

Allow searching, filtering, grouping etc.

The reporting UI will need a datastore of it's own:

  • to store things like group of windows.
  • so a user can club windows with titles "Word", "Excel" into a group called "Work Related" etc.

Misc.

  • Write an email to Stephen Wolfram to find out what tools/scripts he uses to track all this.

Away Time

One of Manic Time features, where it detects inactivity and marks that time as away.

uLogMe has screensaver detection for various DEs.

Application Specific Tracking & Reporting

The current Window title may not be enough for every application, and some other metrics might be nice too!

Current URL of the browser is a nice example, but after enough googling, I found that it's not at all trivial (ManicTime has custom plugins that do this though.)

A workaround for this might be to use browser extensions like this one (for Firefox) that appends the page URL to window title.

This data will then have to be taken into account while performing aggregation in the dashboard, so for eg. regex: ([^\|]*) \| (.*) - .* will extract the page title & url from Firefox windows using the above plugin & | as a separator between title & url.

A similar thing will be needed for Sublime Text. It's window titles are usually of the form: {file-path} • ({project-name}) - Sublime Text and both paths & project name are interesting information to have when focusing on insights. regex: ([^•]*) • \(([^)]*)\) -

Links that might be useful

http://unix.stackexchange.com/questions/5478/what-process-created-this-x11-window

http://superuser.com/questions/382616/detecting-currently-active-window

@guilhas
Copy link

guilhas commented Feb 13, 2017

ProcrastiTracker, Window only
http://strlen.com/procrastitracker/

@ErikBjare
Copy link

Hi there, nice document. (Linked to me here: ActivityWatch/activitywatch#93 (comment))

I've been working on something like this together with my brother for about a year. We're actively developing, so if you're interested in contributing (we'd love to have you) take a look: https://github.com/ActivityWatch/activitywatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment