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 subprocess
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
@ -42,7 +42,7 @@ def set_data(**kwargs):
|
|||||||
def get_mouse_position():
|
def get_mouse_position():
|
||||||
result = subprocess.run(['xdotool', 'getmouselocation', '--shell'], capture_output=True, text=True)
|
result = subprocess.run(['xdotool', 'getmouselocation', '--shell'], capture_output=True, text=True)
|
||||||
output = result.stdout
|
output = result.stdout
|
||||||
# Parse x and y from output
|
|
||||||
x = y = 0
|
x = y = 0
|
||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
if line.startswith('X='):
|
if line.startswith('X='):
|
||||||
@ -64,11 +64,11 @@ if len(sys.argv) > 1:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check if lock file exists
|
|
||||||
if lock_file.exists():
|
if lock_file.exists():
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Create lock file
|
|
||||||
lock_file.touch()
|
lock_file.touch()
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +91,6 @@ try:
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(f"\nTotal distance traveled: {total_distance:.2f} pixels")
|
print(f"\nTotal distance traveled: {total_distance:.2f} pixels")
|
||||||
finally:
|
finally:
|
||||||
# Remove lock file
|
|
||||||
if lock_file.exists():
|
if lock_file.exists():
|
||||||
lock_file.unlink()
|
lock_file.unlink()
|
||||||
|
Loading…
Reference in New Issue
Block a user