git.lucas.co / cce-system-interface
system settings
git clone https://git.lucas.co/cce-system-interface.git

scratch/scroll_and_screenshot.py (1.6K)

 1 import subprocess
 2 import time
 3 from PIL import Image
 4 
 5 def scroll_content():
 6     print("Resetting cursor to top-left...")
 7     subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer move -3000 -3000", shell=True)
 8     time.sleep(0.1)
 9     
10     print("Moving cursor to settings window content area...")
11     subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer move 300 440", shell=True)
12     time.sleep(0.2)
13     
14     print("Clicking to focus settings window...")
15     subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer click left", shell=True)
16     time.sleep(0.3)
17     
18     # Scroll down multiple times
19     print("Scrolling down...")
20     for _ in range(35):
21         subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer scroll -15 0", shell=True)
22         time.sleep(0.05)
23     
24     time.sleep(0.8)
25 
26 scroll_content()
27 
28 # Take screenshot
29 screenshot_path = "/home/lsgalante/.gemini/antigravity/brain/e9f42138-61bb-4037-ac7e-0b1d2091db1c/screenshot_scrolled.png"
30 subprocess.run(f"env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 grim {screenshot_path}", shell=True)
31 print("Screenshot saved.")
32 
33 # Crop the bottom-left area of the window
34 img = Image.open(screenshot_path)
35 wx = 100 * 2
36 wy = 100 * 2
37 ww = 400 * 2
38 wh = 680 * 2
39 crop_box = (wx, wy + wh // 2, wx + ww, wy + wh)
40 cropped = img.crop(crop_box)
41 cropped.save("/home/lsgalante/.gemini/antigravity/brain/e9f42138-61bb-4037-ac7e-0b1d2091db1c/crop_scrolled_final.png")
42 print("Crop saved to crop_scrolled_final.png")