Some checks failed
Build / Test on ubuntu-latest (push) Successful in 2m4s
Examples / Test examples (ubuntu-latest, 3.10) (push) Successful in 2m16s
Lint / lint (push) Successful in 1m25s
Build / Test on macOS-latest (push) Has been cancelled
Build / Test on windows-latest (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1s
17 lines
628 B
Python
17 lines
628 B
Python
from datetime import datetime, time, timedelta, timezone
|
|
import socket
|
|
|
|
import aw_client
|
|
|
|
if __name__ == "__main__":
|
|
bucket_id = f"aw-watcher-afk_{socket.gethostname()}"
|
|
|
|
daystart = datetime.combine(datetime.now().date(), time()).astimezone(timezone.utc)
|
|
dayend = daystart + timedelta(days=1)
|
|
|
|
awc = aw_client.ActivityWatchClient("testclient")
|
|
events = awc.get_events(bucket_id, start=daystart, end=dayend)
|
|
events = [e for e in events if e.data["status"] == "not-afk"]
|
|
total_duration = sum((e.duration for e in events), timedelta())
|
|
print(f"Total time spent on computer today: {total_duration}")
|