Spaces:
Paused
Paused
Utterly fail, cancel pointer click marking
Browse files
app.py
CHANGED
|
@@ -389,82 +389,6 @@ def get_or_create_sandbox(session_hash):
|
|
| 389 |
desktop.stream.start(require_auth=True)
|
| 390 |
setup_cmd = """sudo mkdir -p /usr/lib/firefox-esr/distribution && echo '{"policies":{"OverrideFirstRunPage":"","OverridePostUpdatePage":"","DisableProfileImport":true,"DontCheckDefaultBrowser":true}}' | sudo tee /usr/lib/firefox-esr/distribution/policies.json > /dev/null"""
|
| 391 |
desktop.commands.run(setup_cmd)
|
| 392 |
-
|
| 393 |
-
pointer_highlight_cmd = """#!/bin/bash
|
| 394 |
-
sudo apt update
|
| 395 |
-
sudo apt install -y x11-apps xinput
|
| 396 |
-
|
| 397 |
-
cat << 'EOF' > /tmp/click_marker.sh
|
| 398 |
-
#!/bin/bash
|
| 399 |
-
|
| 400 |
-
echo "$(date): Script started" >> /tmp/click_debug.log
|
| 401 |
-
|
| 402 |
-
# Hardcoded mouse ID from your output
|
| 403 |
-
MOUSE_ID=6
|
| 404 |
-
|
| 405 |
-
# Keep track of current absolute position
|
| 406 |
-
CURRENT_X=0
|
| 407 |
-
CURRENT_Y=0
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
# Monitor raw mouse events
|
| 411 |
-
xinput test $MOUSE_ID | while read event; do
|
| 412 |
-
echo "$(date): Event: $event" >> /tmp/click_debug.log
|
| 413 |
-
|
| 414 |
-
# Update position from motion events
|
| 415 |
-
if echo "$event" | grep -q "motion"; then
|
| 416 |
-
# Extract absolute position values
|
| 417 |
-
if echo "$event" | grep -q "absolute"; then
|
| 418 |
-
X_VAL=$(echo "$event" | grep -o "a\[0\]=.*" | cut -d= -f2 | cut -d' ' -f1)
|
| 419 |
-
Y_VAL=$(echo "$event" | grep -o "a\[1\]=.*" | cut -d= -f2 | cut -d' ' -f1)
|
| 420 |
-
|
| 421 |
-
if [ ! -z "$X_VAL" ]; then
|
| 422 |
-
CURRENT_X=$X_VAL
|
| 423 |
-
fi
|
| 424 |
-
if [ ! -z "$Y_VAL" ]; then
|
| 425 |
-
CURRENT_Y=$Y_VAL
|
| 426 |
-
fi
|
| 427 |
-
|
| 428 |
-
echo "$(date): Position updated to $CURRENT_X,$CURRENT_Y" >> /tmp/click_debug.log
|
| 429 |
-
fi
|
| 430 |
-
fi
|
| 431 |
-
|
| 432 |
-
# Check if this is a button press event
|
| 433 |
-
if echo "$event" | grep -q "button press"; then
|
| 434 |
-
echo "$(date): Button press detected at $CURRENT_X,$CURRENT_Y" >> /tmp/click_debug.log
|
| 435 |
-
|
| 436 |
-
# Show xlogo at current position
|
| 437 |
-
xlogo -geometry 40x40+$CURRENT_X+$CURRENT_Y &
|
| 438 |
-
LOGO_PID=$!
|
| 439 |
-
echo "$(date): Started xlogo with PID $LOGO_PID" >> /tmp/click_debug.log
|
| 440 |
-
|
| 441 |
-
# Keep xlogo open for 2 seconds
|
| 442 |
-
sleep 2
|
| 443 |
-
|
| 444 |
-
# Kill xlogo
|
| 445 |
-
kill $LOGO_PID 2>/dev/null
|
| 446 |
-
echo "$(date): Closed xlogo" >> /tmp/click_debug.log
|
| 447 |
-
fi
|
| 448 |
-
done
|
| 449 |
-
|
| 450 |
-
echo "$(date): Script exited unexpectedly" >> /tmp/click_debug.log
|
| 451 |
-
EOF
|
| 452 |
-
|
| 453 |
-
# Make the script executable
|
| 454 |
-
chmod +x /tmp/click_marker.sh
|
| 455 |
-
|
| 456 |
-
# Create a setup log entry
|
| 457 |
-
echo "Click marker setup completed at $(date)" > /tmp/click_marker_setup.log
|
| 458 |
-
|
| 459 |
-
# Launch the script with nohup to keep it running after terminal closes
|
| 460 |
-
nohup /tmp/click_marker.sh > /dev/null 2>&1 &
|
| 461 |
-
|
| 462 |
-
# Record the PID in the log file
|
| 463 |
-
echo "Running with PID: $!" >> /tmp/click_marker_setup.log
|
| 464 |
-
echo "To stop it, run: kill $!" >> /tmp/click_marker_setup.log
|
| 465 |
-
"""
|
| 466 |
-
desktop.commands.run(pointer_highlight_cmd)
|
| 467 |
-
|
| 468 |
|
| 469 |
# Store sandbox with metadata
|
| 470 |
SANDBOXES[session_hash] = desktop
|
|
|
|
| 389 |
desktop.stream.start(require_auth=True)
|
| 390 |
setup_cmd = """sudo mkdir -p /usr/lib/firefox-esr/distribution && echo '{"policies":{"OverrideFirstRunPage":"","OverridePostUpdatePage":"","DisableProfileImport":true,"DontCheckDefaultBrowser":true}}' | sudo tee /usr/lib/firefox-esr/distribution/policies.json > /dev/null"""
|
| 391 |
desktop.commands.run(setup_cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
|
| 393 |
# Store sandbox with metadata
|
| 394 |
SANDBOXES[session_hash] = desktop
|