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

scratch/scroll_keybindings.py (1.8K)

 1 import subprocess
 2 import time
 3 from PIL import Image
 4 
 5 # Kill exact binary path to avoid matching this python script path
 6 print("Killing existing settings process...")
 7 subprocess.run('pkill -f "/home/lsgalante/.local/bin/cce-settings"', shell=True)
 8 time.sleep(0.5)
 9 
10 print("Starting settings application...")
11 subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 /home/lsgalante/.local/bin/cce-settings &", shell=True)
12 time.sleep(1.5)
13 
14 print("Focusing window...")
15 subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl toplevel focus title:'CCE System Settings'", shell=True)
16 time.sleep(0.3)
17 
18 print("Resetting cursor...")
19 subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer move -3000 -3000", shell=True)
20 time.sleep(0.1)
21 
22 print("Moving cursor to safe spot...")
23 subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer move 380 250", shell=True)
24 time.sleep(0.2)
25 
26 print("Scrolling down...")
27 for _ in range(45):
28     subprocess.run("env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlrctl pointer scroll -15 0", shell=True)
29     time.sleep(0.04)
30 
31 time.sleep(0.8)
32 
33 # Take screenshot
34 screenshot_path = "/home/lsgalante/.gemini/antigravity/brain/e9f42138-61bb-4037-ac7e-0b1d2091db1c/screenshot_scrolled_ok.png"
35 subprocess.run(f"env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 grim {screenshot_path}", shell=True)
36 print("Screenshot saved.")
37 
38 # Crop Keybindings
39 img = Image.open(screenshot_path)
40 wx = 100 * 2
41 wy = 100 * 2
42 ww = 400 * 2
43 wh = 680 * 2
44 crop_box = (wx, wy + wh // 2, wx + ww, wy + wh)
45 cropped = img.crop(crop_box)
46 cropped.save("/home/lsgalante/.gemini/antigravity/brain/e9f42138-61bb-4037-ac7e-0b1d2091db1c/crop_scrolled_final.png")
47 print("Crop saved.")