Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/mouseinfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ def _macGetPixel(x, y):
else:
raise

_display = Display(os.environ['DISPLAY'])
_display = Display(os.environ['DISPLAY']) if 'DISPLAY' in os.environ else None

def _linuxPosition():
if _display is None:
return
coord = _display.screen().root.query_pointer()._data
return coord["root_x"], coord["root_y"]
position = _linuxPosition
Expand Down Expand Up @@ -251,6 +253,8 @@ def _linuxScreenshot(filename=None):
screenshot = _linuxScreenshot

def _linuxSize():
if _display is None:
return
return _display.screen().width_in_pixels, _display.screen().height_in_pixels
size = _linuxSize

Expand Down