https://activitywatch.readthedocs.io/en/latest/querying-data.html#writing-a-query Sorry for the bad documentation of the queries, we’re porting aw-server to rust where there’s a lot of improvements to the queries so I’ve not put much time to improve the documentation as it’s not been much of a priority.
If you’d want to know how much time you spend in notepad.exe only without AFK filtering, this would be the query
events = query_bucket("aw-watcher-window_johan-laptop2");
events = filter_keyvals(events, "app", ["notepad.exe"]);
events = merge_events_by_keys(events, ["app"]);
RETURN = events;
- First row gets all events from the bucket “aw-watcher-window_johan-laptop2”
- Second row removes all events which do not has the key “app” set to “notepad.exe”.
- Third row merges the list of all events by the value of the “app” field into one event for each unique value (and since we filtered for “notepad.exe” there should only be a single event)
- Fourth row tells us what data should be responded
If you remove the second row you will get something very similiar to what the web-ui shows as the “app summary”, only thing different is that it ignores AFK time and doesn’t sort by duration.
If you only want the data for the last hour you filter the timeperiod with the starttime and endtime fields.
It’s very easy to quickly accomplish this with the cli.py script, for example I just put the query in a file and executed it with ./aw_client/cli.py query notepad_query.txt