Fixed mouse.py
This commit is contained in:
parent
05d288f8c5
commit
c28b9029f3
10
mouse.py
10
mouse.py
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
import math
|
||||
@ -42,7 +42,7 @@ def set_data(**kwargs):
|
||||
def get_mouse_position():
|
||||
result = subprocess.run(['xdotool', 'getmouselocation', '--shell'], capture_output=True, text=True)
|
||||
output = result.stdout
|
||||
# Parse x and y from output
|
||||
|
||||
x = y = 0
|
||||
for line in output.splitlines():
|
||||
if line.startswith('X='):
|
||||
@ -64,11 +64,11 @@ if len(sys.argv) > 1:
|
||||
|
||||
|
||||
|
||||
# Check if lock file exists
|
||||
|
||||
if lock_file.exists():
|
||||
sys.exit(0)
|
||||
|
||||
# Create lock file
|
||||
|
||||
lock_file.touch()
|
||||
|
||||
|
||||
@ -91,6 +91,6 @@ try:
|
||||
except KeyboardInterrupt:
|
||||
print(f"\nTotal distance traveled: {total_distance:.2f} pixels")
|
||||
finally:
|
||||
# Remove lock file
|
||||
|
||||
if lock_file.exists():
|
||||
lock_file.unlink()
|
||||
|
Loading…
Reference in New Issue
Block a user