Skip to content

Instantly share code, notes, and snippets.

@NicoWeio
Created May 7, 2022 14:25
Show Gist options
  • Save NicoWeio/c0991e1023c4d9869157cc46e7f2ffa8 to your computer and use it in GitHub Desktop.
Save NicoWeio/c0991e1023c4d9869157cc46e7f2ffa8 to your computer and use it in GitHub Desktop.
time spent on a domain | Query for ActivityWatch
# Returns the total non-AFK time spent on a specific domain.
# Note that this doesn't care if the browser is in focus.
# Paste this into http://localhost:5600/#/query
# Tested for ActivityWatch 0.11.0
afk_events = query_bucket(find_bucket("aw-watcher-afk_"));
web_events = query_bucket(find_bucket("aw-watcher-web")); # doesn't work with multiple browsers; pass a specific bucket name like "aw-watcher-web-firefox" if necessary
web_events = split_url_events(web_events);
DOMAINS = ["youtube.com"];
domain_events = filter_keyvals(web_events, "$domain", DOMAINS);
non_afk_events = filter_keyvals(afk_events, "status", ["not-afk"]);
window_events = filter_period_intersect(web_events, non_afk_events);
RETURN = sum_durations(domain_events);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment