Skip to content

Commit

Permalink
fix: fixed lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Oct 25, 2023
1 parent 2b638db commit 575a6f5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
3 changes: 2 additions & 1 deletion aw_watcher_afk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import __main__
from .__main__ import main

__all__ = ["main"]
1 change: 0 additions & 1 deletion aw_watcher_afk/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
from datetime import datetime, timedelta, timezone
from time import sleep
from typing import Optional

from aw_core.models import Event
from aw_client import ActivityWatchClient
Expand Down
1 change: 0 additions & 1 deletion aw_watcher_afk/macos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from Quartz.CoreGraphics import (CGEventSourceSecondsSinceLastEventType,
kCGEventSourceStateHIDSystemState,
kCGAnyInputEventType)
Expand Down
7 changes: 3 additions & 4 deletions aw_watcher_afk/unix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from datetime import datetime
from time import sleep

from .listeners import KeyboardListener, MouseListener

Expand All @@ -25,8 +26,8 @@ def seconds_since_last_input(self) -> float:
self.logger.debug("New event")
self.last_activity = now
# Get/clear events
mouse_event = self.mouseListener.next_event()
keyboard_event = self.keyboardListener.next_event()
self.mouseListener.next_event()
self.keyboardListener.next_event()
return (now - self.last_activity).total_seconds()


Expand All @@ -43,8 +44,6 @@ def seconds_since_last_input():


if __name__ == "__main__":
from time import sleep

while True:
sleep(1)
print(seconds_since_last_input())
22 changes: 9 additions & 13 deletions aw_watcher_afk/windows.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import time

import ctypes
from ctypes import Structure, POINTER, WINFUNCTYPE, windll # type: ignore
from ctypes.wintypes import BOOL, UINT, DWORD # type: ignore
import time
from ctypes import POINTER, WINFUNCTYPE, Structure
from ctypes.wintypes import BOOL, DWORD, UINT


class LastInputInfo(Structure):
_fields_ = [
("cbSize", UINT),
("dwTime", DWORD)
]
_fields_ = [("cbSize", UINT), ("dwTime", DWORD)]


def _getLastInputTick() -> int:
prototype = WINFUNCTYPE(BOOL, POINTER(LastInputInfo))
paramflags = ((1, "lastinputinfo"), )
paramflags = ((1, "lastinputinfo"),)
c_GetLastInputInfo = prototype(("GetLastInputInfo", ctypes.windll.user32), paramflags) # type: ignore

l = LastInputInfo()
l.cbSize = ctypes.sizeof(LastInputInfo)
assert 0 != c_GetLastInputInfo(l)
return l.dwTime
lastinput = LastInputInfo()
lastinput.cbSize = ctypes.sizeof(LastInputInfo)
assert 0 != c_GetLastInputInfo(lastinput)
return lastinput.dwTime


def _getTickCount() -> int:
Expand Down

0 comments on commit 575a6f5

Please sign in to comment.