Skip to content

Xorg afk watcher random afk/non-afk #135

Closed

Description

@MaZZly

I was previously running Wayland with AW to track work time spent in front of the computer, but due to input lag (probably caused by 4k monitor+Wayland) I switched over to Xorg session, where things run more smoothly.

I realized that my simple python script for extracting work hours, started showing odd hours, even over the weekends, while I wasn't using the computer.

Checking the afk-buckets, there are afk/non-afk entries at random points when the computer was not in use, while checking the window-watcher-buckets, there are no entries/active windows for those times.

It seems that even though the computer is logged out (gnome login-screen) it will do some events that are tracked as not-afk.

Simple solution for me now:

  1. suspend computer (energy savings yayy, which is probably what I should be doing anyway)
  2. modify my work-hour script to use the json from window-watcher to extract the hours.

Also:
Is there some way to remove entries for those times when it wasn't tracked correctly?

Activity

  1. ErikBjare commented on Nov 21, 2017

    @ErikBjare
    Member

    Thanks for filing this, good questions!

    I was previously running Wayland with AW to track work time spent in front of the computer, but due to input lag (probably caused by 4k monitor+Wayland) I switched over to Xorg session, where things run more smoothly.

    Just to clarify, AW wasn't the cause of lag? I'm slightly worried it could be... (we don't support Wayland anyway right now, but would be good to know for when we start working on it).

    I realized that my simple python script for extracting work hours, started showing odd hours, even over the weekends, while I wasn't using the computer.

    Checking the afk-buckets, there are afk/non-afk entries at random points when the computer was not in use, while checking the window-watcher-buckets, there are no entries/active windows for those times.

    It seems that even though the computer is logged out (gnome login-screen) it will do some events that are tracked as not-afk.

    That's strange, the only events we listen to are mouse and keyboard events. Perhaps your mouse randomly sends off an event? I've noticed mine doing that sometimes.

    I'm guessing the unexpected non-afk periods have a zero, or near-zero, duration?

    Is there some way to remove entries for those times when it wasn't tracked correctly?

    Good question: Apparently there isn't! I can add the API endpoint required (should be easy), it would land in the next version (0.7.2) and then you would just simply use aw-client to call the REST API (or call the API directly if that's your thing). I'm tracking the thing in #136

  2. MaZZly commented on Nov 23, 2017

    @MaZZly
    Author

    Nah I think Wayland itself in combination with 4k monitor might be the problem. Also noticed this lag before installing ActivityWatch.

    I guess I could try turning off the mouse at the end of the day to test it.

    Sounds good with removal of entries, this way I could remove those odd ones if exists.

    Anyway I guess I should modify my script to use the window watcher json dump instead as that one might be more reliable.

  3. MaZZly commented on Nov 23, 2017

    @MaZZly
    Author

    hmm looking closer at the AFK-json, the weird non-afk events seem to have a duration of
    180.XXX (so almost exactly 3 minutes).. I could probably just check to ignore if "178 < duration < 182"
    and the maximum error in my reporting would be +/- 3m, which is acceptable.

    Would be interesting to know what seem to wake the computer for 180s every now and then tho =D

  4. ErikBjare commented on Nov 23, 2017

    @ErikBjare
    Member

    Those 180s doesn't bode well. I think that means we have a bug in the AFK watcher since that's the default "timeout" duration (the time you have to be inactive for the period to be counted as AFK).

    I looked at the source, and it seems we're sending heartbeats that the user is still not AFK despite not receiving any new input. What do you think @johan-bjareholt?

  5. johan-bjareholt commented on Nov 23, 2017

    @johan-bjareholt
    Member

    @ErikBjare Seems so. I am running the old commit which still has hibernation support (c1f6d73425fe7f6c) because I liked that functionality where it seems to be working differently

    master

    ...
    # Send a heartbeat if no state change was made
    else:
        self.ping(self.afk)
    

    the old commit i'm running on (c1f6d73425fe7f6c)

    ...
    # Send a heartbeat if no state change was made
    else:
        if self.afk:
            self.ping(self.afk)
        elif self.seconds_since_last_input < self.settings.polling_interval:
            self.ping(self.afk)
    

    The commit I'm running certainly looks more correct

  6. added this to the milestone on Nov 24, 2017
  7. johan-bjareholt commented on Dec 22, 2017

    @johan-bjareholt
    Member
  8. modified the milestones: , v0.8 on Feb 12, 2018
  9. ErikBjare commented on May 29, 2018

    @ErikBjare
    Member

    I assume this was solved by ActivityWatch/aw-watcher-afk#31, closing.

  10. added a commit that references this issue on Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions