Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mark as AFK when lock screen is shown #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amsam0
Copy link

@amsam0 amsam0 commented Oct 25, 2024

Resolves #66. The user will be marked as AFK if the lock screen is shown and if the user hasn't made inputs for at least 5 seconds. There is currently no configuration option for this amount of time since it seemed unnecessary and this is just a quick check in case the user is doing something on their lock screen.

No changes were made to how the user will be marked as no longer AFK, since the inputs check will already catch them logging back into their machine.

Appears to be working on my macOS machine. I have not added implementations for Windows and Linux.

This PR has not been formatted since I'm not sure what formatter ActivityWatch uses, and since I'm only contributing small fixes and improvements, I haven't taken the time to setup a proper development environment.


Important

Adds AFK detection when lock screen is shown with 5-second inactivity threshold for macOS, with placeholders for Windows and Linux.

  • Behavior:
    • Marks user as AFK if lock screen is shown and no input for 5 seconds in afk.py.
    • No configuration for 5-second threshold; assumed unnecessary.
    • No changes to how user is marked as no longer AFK.
  • Platform Support:
    • Implemented for macOS in macos.py using CGSessionCopyCurrentDictionary.
    • Placeholder functions for Windows and Linux in windows.py and unix.py.
  • Logging:
    • Added debug logs for lock screen status in afk.py.

This description was created by Ellipsis for b095e65. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to b095e65 in 33 seconds

More details
  • Looked at 110 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. aw_watcher_afk/unix.py:48
  • Draft comment:
    The lock_screen_shown function is not implemented for Linux. This will cause the feature to not work on Linux systems. Consider implementing this function to detect if the lock screen is shown on Linux.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is directly related to a change in the diff, specifically the addition of the lock_screen_shown function. It highlights a potential issue with the current implementation, which is a placeholder. The comment is actionable as it suggests implementing the function for Linux.
    The comment might be considered redundant since the code already includes a TODO comment indicating the need for a Linux implementation. However, it does provide additional context on the impact of not implementing the function.
    While the TODO comment indicates the need for implementation, the review comment emphasizes the importance of this implementation for Linux functionality, which could be valuable for the author.
    The comment should be kept as it highlights an important issue with the current placeholder implementation and suggests a necessary action.
2. aw_watcher_afk/afk.py:13
  • Draft comment:
    The code has not been formatted. Please format the code to improve readability and maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR description mentions that the code has not been formatted. It's important to ensure code is properly formatted for readability and maintainability.

Workflow ID: wflow_3SmZurAeGU9oo66B


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -26,6 +26,11 @@ def _getTickCount() -> int:
return c_GetTickCount()


def lock_screen_shown() -> bool:
# TODO: Windows implementation
return False
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lock_screen_shown function is not implemented for Windows. This will cause the feature to not work on Windows systems. Consider implementing this function to detect if the lock screen is shown on Windows.

@amsam0
Copy link
Author

amsam0 commented Nov 9, 2024

@ErikBjare any chance of this getting merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[macOS] Set state to AFK when screen is locked or computer is asleep
1 participant