phroi/vscode-focus-timer

★ 0Forks 0TypeScriptGitHub ↗Compare

README

Focus Timer

VS Code extension that tracks focused editor time per project.

Opt-in

Tracking is off by default. To enable it for a project, create the timer file in the project root:

touch .focus-timer

Add it to .gitignore to keep it out of version control:

echo .focus-timer >> .gitignore

How it works

While VS Code is focused, the extension accumulates time in memory. Minutes (rounded up) are appended to .focus-timer approximately every 10 focused minutes and when the editor closes. Rounding overshoot is subtracted from the next write to keep the running total accurate.

Brief breaks (up to 10 minutes) receive partial credit via linear decay, so short interruptions don't fragment your session.

The file is append-only, one number per line:

12
5
3

Total focused time = sum of all lines (in minutes).

Reset

Delete or truncate the file:

rm .focus-timer     # opt out and clear
> .focus-timer      # clear but keep tracking

Development

pnpm install
pnpm build        # compile to dist/
pnpm watch        # compile on change
pnpm lint         # eslint
pnpm check:full   # clean-room validation (deletes lockfile, node_modules, dist)
pnpm package      # install deps and compile to dist/

Press F5 in VS Code to launch an Extension Development Host with the extension loaded.

Install

The compiled extension is tracked in git, so no build step is needed.

ln -sfn "$PWD" ~/.vscode/extensions/phroi.focus-timer

Restart VS Code after creating the symlink.

Devcontainer

To auto-install this extension in a devcontainer, symlink the checkout that is already available inside the container into VS Code Server:

"postCreateCommand": {
  "focus-timer": "d=/path/to/vscode-focus-timer && mkdir -p ~/.vscode-server/extensions && ln -sfn \"$d\" ~/.vscode-server/extensions/phroi.focus-timer"
}

Licensing

Released under the MIT License.

Contributors

phroi

Issues