karlicoss / HPI

Human Programming Interface 🧑👽🤖
https://beepb00p.xyz/hpi.html
MIT License
1.47k stars 61 forks source link

module suggestion: ActivityWatch #64

Open alexriabtsev opened 4 years ago

alexriabtsev commented 4 years ago

Is there any way to import ActivityWatch info? They have API with docs - https://docs.activitywatch.net/en/latest/rest.html

purarue commented 4 years ago

I've played around with this a bit, and the docs don't really document everything that well (seems they've been in the process of migrating to rust-based core as well). had to go and poke in here, and couldn't get the delete route to work after fiddling with it for a bit. However, I was able to get event data from it, so that wouldn't be a limiting factor, at least for now.

I'm not sure how this would work with multiple buckets/generic events either. The window watcher/afk modules are standard, but how would one support loading in arbitrary data buckets?

As it says there:

The API is currently under development, and is subject to change. It will be documented in better detail when first version has been frozen.

I really did like aw-window-watcher though, so I ended up forking that to log to a CSV file instead, and have a data loader for that in my.window_watcher

Generally curious if you're using ActivityWatcher for anything else, is there some data you'd want to expose through the API?

madelinecameron commented 3 years ago

:wave: I wrote a basic interface for ActivityWatch.

My extractor & DAL code is here: https://github.com/hpi/activitywatch

My synchronization code is https://github.com/hpi/aw-sync-client and https://github.com/hpi/aw-sync-server

It works alright from what I've seen but there could still be fiddling needed. The way I accomplished this is using the query endpoints then synchronizing to an off-site server (not at all required tbh, I should modify the extractor to call directly), then my extractor (currently) calls out to my external AW sync server.

I did this so I can run AW on my personal Linux & WIndows along with any work computers.

krillin666 commented 2 years ago

wave I wrote a basic interface for ActivityWatch.

My extractor & DAL code is here: hpi/activitywatch

My synchronization code is hpi/aw-sync-client and hpi/aw-sync-server

It works alright from what I've seen but there could still be fiddling needed. The way I accomplished this is using the query endpoints then synchronizing to an off-site server (not at all required tbh, I should modify the extractor to call directly), then my extractor (currently) calls out to my external AW sync server.

I did this so I can run AW on my personal Linux & WIndows along with any work computers.

Couldn't this be merged to HPI ?

purarue commented 2 years ago

It could be, but it doesnt have to be for you to use it -- if you have the client/server setup and you have this installed as editable, you can do something like what I describe here:

git clone 'https://github.com/madelinecameron/hpi' ./HPI-madeline
pip install -e ./HPI-madeline
hpi module install my.activitywatch

hpi doctor -S my.activitywatch

you can then import my.activitywatch as normal, as if it was merged into this repo (because it sort of is, HPI is a namespace package and namespace packages merge multiple folder structures into one module)

purarue commented 1 year ago

Since Ive started using activitywatch on my android and windows machines, I also published a basic library to parse the JSON dump from activitywatch here, with the corresponding HPI file in my modules (see here for install instructions)

This only does the window titles/app names in particular with timestamps/durations, since thats what Ive always been interested in from activitywatch