Skip to content

Commit

Permalink
fix: moved pynput imports inside methods to prevent failing on import…
Browse files Browse the repository at this point in the history
… when no Xorg available
  • Loading branch information
ErikBjare committed Apr 19, 2021
1 parent 61bf58e commit d543bdd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aw_watcher_afk/listeners.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import logging
import threading

from pynput import keyboard
from pynput import mouse

logger = logging.getLogger(__name__)


Expand All @@ -24,6 +21,8 @@ def __init__(self):
self._reset_data()

def start(self):
from pynput import keyboard

listener = keyboard.Listener(on_press=self.on_press, on_release=self.on_release)
listener.start()

Expand Down Expand Up @@ -63,6 +62,8 @@ def _reset_data(self):
self.event_data = {"clicks": 0, "deltaX": 0, "deltaY": 0}

def start(self):
from pynput import mouse

listener = mouse.Listener(
on_move=self.on_move, on_click=self.on_click, on_scroll=self.on_scroll
)
Expand Down

0 comments on commit d543bdd

Please sign in to comment.