Export ActivityWatch data to TimeWarrior with rule-based tag categorization
Project description
Better Categorizer and Timewarrior Companion
Problem: ActivityWatch collects great data, but it's hard to get useful insights from it.
Solution: Rule-based categorization that transforms raw ActivityWatch events into meaningful tags with multiple output options.
Currently this script exports data from ActivityWatch into TimeWarrior, but I'm planning to let this be a general categorization/tagging tool with possibility to store things in different backends, possibly including to work as a watcher and reexport data back into ActivityWatch.
What it does
- Categorizes ActivityWatch events using configurable rules (browser URLs, editor files, app names, tmux sessions)
- Exports categorized activity to TimeWarrior for time tracking
- Report and analyze commands to aid the user into tweaking the rules and configuration and reexporting the data.
Installation
Let me know if you try it or start using it. Following the SemVer standard, I'm free to break backward compatibility in the 0.x-series - and if I believe I'm the only user, I will most likely do that without any notice.
Installation from PyPI
pip install aw-export-timewarrior
Installation from Source
git clone https://github.com/tobixen/aw-export-timewarrior
cd aw-export-timewarrior
make install
Running as a Systemd Service
For continuous sync mode, you can run as a systemd user service:
make enable-service # Install and start the service
Check status and logs:
systemctl --user status aw-export-timewarrior
journalctl --user -u aw-export-timewarrior -f
Requirements
- Python - It's currently only tested with 3.13. If you want to use it with other versions, let me know.
- ActivityWatch with aw-watcher-window running
- TimeWarrior installed
Optional Watchers
For richer tag extraction, install additional watchers:
- aw-watcher-web - Extract tags from browser URLs
- aw-watcher-vim - Extract tags from Vim file paths
- activity-watch-mode - Extract tags from Emacs file paths
- aw-watcher-tmux - Extract tags from tmux sessions
- aw-watcher-afk-prompt - Prompt for activity description after AFK periods (legacy name: aw-watcher-ask-away)
- aw-watcher-afk-lid - Track AFK based on laptop lid state
Support for other watchers may be considered, reach out by email or add an issue or pull request for it.
Quick Start
# Continuous sync mode
aw-export-timewarrior sync
# Compare ActivityWatch data with TimeWarrior (dry-run)
aw-export-timewarrior diff --day yesterday
# Apply suggested changes
aw-export-timewarrior diff --day yesterday --apply
# Gain insight into events and rules
aw-export-timewarrior report --from '2 hours ago' --show-rule
aw-export-timewarrior analyze --day yesterday --limit 30
Configuration
Configuration is stored in ~/.config/activitywatch/aw-export-timewarrior/aw-export-timewarrior.toml.
Rule Types
- Browser rules (
rules.browser.*): Match URLs withurl_regexp - Editor rules (
rules.editor.*): Match byprojectname orpath_regexp - App rules (
rules.app.*): Match byapp_namesandtitle_regexp - Tmux rules (
rules.tmux.*): Match bysession,window,command,path - Tag rules (
tags.*): Transform tags withadd,remove,replaceoperations - Exclusive rules (
exclusive.*): Prevent conflicting tags from combining
Example Configuration
[rules.browser.github]
url_regexp = "github\\.com"
tags = ["coding", "github"]
[rules.editor.myproject]
path_regexp = "/home/user/projects/myproject"
tags = ["myproject", "coding"]
[rules.app.slack]
app_names = ["slack", "Slack"]
tags = ["communication", "slack"]
[tags.coding-is-work]
source_tags = ["coding"]
add = ["4WORK"]
[exclusive.afk]
tags = ["afk", "not-afk"]
Commands
| Command | Description |
|---|---|
sync |
Continuous sync from ActivityWatch to TimeWarrior |
diff |
Compare and generate correction commands |
report |
Show activity report with tags |
analyze |
Analyze events without exporting |
timeline |
Show side-by-side ActivityWatch vs TimeWarrior |
validate |
Validate configuration file |
Use --help with any command for detailed options.
Development
make install-dev # Install with dev dependencies
make test # Run tests
make lint # Run ruff check
make format # Run ruff format
make clean # Remove build artifacts
make help # Show all available targets
Documentation
- Tracking Algorithm - How events are processed and exported
- Testing Guide - Running and writing tests
- TODO / Changelog - Completed features and planned work
Background
This tool bridges ActivityWatch (automatic activity tracking) and TimeWarrior (manual time tracking). See the blog posts for rationale:
- General thoughts on time tracking
- Comparison of different software
- Early experiences on combinging AW and TW
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aw_export_timewarrior-0.6.5.tar.gz.
File metadata
- Download URL: aw_export_timewarrior-0.6.5.tar.gz
- Upload date:
- Size: 88.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
791764e1a8e4d70cbc4e380671eab8328e11cb104d57583faed702b78488f6d5
|
|
| MD5 |
0f09b6e1e03e3f874bb6e6b5e48a59ae
|
|
| BLAKE2b-256 |
756b755a3399d6432b5fceaf7d9ba058aab26e8c81fd5a162a5ec785c38be8aa
|
Provenance
The following attestation bundles were made for aw_export_timewarrior-0.6.5.tar.gz:
Publisher:
publish.yml on tobixen/aw-export-timewarrior
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aw_export_timewarrior-0.6.5.tar.gz -
Subject digest:
791764e1a8e4d70cbc4e380671eab8328e11cb104d57583faed702b78488f6d5 - Sigstore transparency entry: 863934990
- Sigstore integration time:
-
Permalink:
tobixen/aw-export-timewarrior@b41dcc5fb7549b51b9cbe169ddf69ca51863cf72 -
Branch / Tag:
refs/tags/v0.6.5 - Owner: https://github.com/tobixen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b41dcc5fb7549b51b9cbe169ddf69ca51863cf72 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aw_export_timewarrior-0.6.5-py3-none-any.whl.
File metadata
- Download URL: aw_export_timewarrior-0.6.5-py3-none-any.whl
- Upload date:
- Size: 96.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af04f72a577a4623b3817d82ae793c609c9a91b7cf62c3027b2afd43036a57d8
|
|
| MD5 |
25487b91423a371afc46827324446630
|
|
| BLAKE2b-256 |
86b74a31f2d804581a28342154d9aac6cf9002fbebdd8d9aa4955df1cd8ff2ae
|
Provenance
The following attestation bundles were made for aw_export_timewarrior-0.6.5-py3-none-any.whl:
Publisher:
publish.yml on tobixen/aw-export-timewarrior
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aw_export_timewarrior-0.6.5-py3-none-any.whl -
Subject digest:
af04f72a577a4623b3817d82ae793c609c9a91b7cf62c3027b2afd43036a57d8 - Sigstore transparency entry: 863934994
- Sigstore integration time:
-
Permalink:
tobixen/aw-export-timewarrior@b41dcc5fb7549b51b9cbe169ddf69ca51863cf72 -
Branch / Tag:
refs/tags/v0.6.5 - Owner: https://github.com/tobixen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b41dcc5fb7549b51b9cbe169ddf69ca51863cf72 -
Trigger Event:
push
-
Statement type: