ActivityWatch / activitywatch

The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.
https://activitywatch.net/
Mozilla Public License 2.0
11.73k stars 533 forks source link

ActivityWatch counted computer sleep time as not-AFK #854

Closed mooskagh closed 1 year ago

mooskagh commented 1 year ago

Describe the bug

I've closed the laptop lid to put it into the sleep mode. In the morning when I woke up my laptop, the entire night time was marked as "not-AFK". Snipped from the log file (see the period between 02:09:27 and 09:02:27):

2023-03-16 22:31:13 [INFO ]: Became AFK  (aw_watcher_afk.afk:97)
2023-03-16 22:31:23 [INFO ]: Received heartbeat after pulse window, inserting as new event. (bucket: aw-watcher-afk_crem)  (aw_server.api:284)
2023-03-16 22:36:32 [INFO ]: Received heartbeat after pulse window, inserting as new event. (bucket: aw-watcher-window_crem)  (aw_server.api:284)
2023-03-17 02:09:27 [INFO ]: No longer AFK  (aw_watcher_afk.afk:90)
2023-03-17 09:02:27 [INFO ]: Received heartbeat after pulse window, inserting as new event. (bucket: aw-watcher-window_crem)  (aw_server.api:284)
2023-03-17 09:05:14 [INFO ]: Became AFK  (aw_watcher_afk.afk:97)
2023-03-17 09:05:14 [INFO ]: Received heartbeat after pulse window, inserting as new event. (bucket: aw-watcher-afk_crem)  (aw_server.api:284)
2023-03-17 09:05:24 [INFO ]: Received heartbeat after pulse window, inserting as new event. (bucket: aw-watcher-afk_crem)  (aw_server.api:284)
2023-03-17 09:08:34 [INFO ]: No longer AFK  (aw_watcher_afk.afk:90)
github-actions[bot] commented 1 year ago

Hi there! As you're new to this repo, please make sure you've used an appropriate issue template and searched for duplicates (it helps us focus on actual development!). We'd also like to suggest that you read our contribution guidelines and our code of conduct. Thanks a bunch for opening your first issue! 🙏

BelKed commented 1 year ago

So, I assume you put your laptop to sleep around 22:31:13 then it woke up at 02:09:27 because of Wi-Fi wake up command or something like this or just because the connected mouse moved. And maybe the mouse was moving the whole time or the system was sleeping really hard so the Became AFK pulse never occurred till 09:05:14.

But I’m not that sure what exactly happened…

mooskagh commented 1 year ago

I'll try to reproduce it again and watch closer in which state it is at which moment.

I closed the lid at 22:31:13, but I suspect it actually went to sleep at 02:09:27.
At least when I close the lid, it usually doesn't go to sleep imediately, and in the morning I find the laptop in the sleep state...

Ok, actually what the systemd-sleep log says is:

...
Mar 15 09:16:30 crem systemd-sleep[273426]: Entering sleep state 'suspend'...
Mar 15 09:16:40 crem systemd-sleep[273426]: System returned from sleep state.
Mar 17 08:39:33 crem systemd-sleep[856049]: Entering sleep state 'suspend'...
Mar 17 09:02:10 crem systemd-sleep[856049]: System returned from sleep state.

...meaning it wasn't sleeping in the night, and not detecting AFK is probably not related to the sleep.

I'm closing this issue for now, and will reopen if I have more data.