Apparently I am a good level of tech-savviness for vibe-coding a Linux version of
this thing.
"Write, from scratch, a program that monitors a specified area of the screen and makes an alert sound if any of the pixels in it turn white": beyond my skill level.
"Here is a Python script that monitors a specified area of the screen and makes an alert sound if any of the pixels in it turn white! It has one (1) critical bug causing it to silently fail. Figure out that the bug exists, then track it down, then fix it": *not* beyond my skill level, actually.
---
(I *was* originally running the linked program in a Windows 7 virtual machine (connected to the Internet, but not logged into anything), but at least one of the following possible explanations had started to happen:
(1) Windows was pissed that I didn't give them a software key and, after a grace period, started throttling me.
(2) The updates Windows 7 had downloaded (apparently Microsoft is still running update servers for 7, just not uploading new patches to them?) had increased its minimum viable specs beyond the specs I'd given the VM.
(3) It was getting clogged with viruses.
(4) Other.
A Linux Lite VM should be better at these. (Except maybe "other".))
---
the code (click to expand)
import time
from PIL import Image
import os
# Define region to monitor: left, top, width, height
REGION = (100, 100, 200, 150) # x, y, w, h
# Path for temp screenshot
SCREENSHOT = "/tmp/screen_region.png"
SOUND = "/usr/share/sounds/freedesktop/stereo/complete.oga" # replace if needed
def capture_region():
os.system(f"scrot -o -a {REGION[0]},{REGION[1]},{REGION[2]},{REGION[3]} {SCREENSHOT}")
def contains_white_pixel(image_path):
img = Image.open(image_path)
pixels = img.getdata()
return any(pixel[:3] == (255, 255, 255) for pixel in pixels)
while True:
capture_region()
if contains_white_pixel(SCREENSHOT):
os.system(f"ffplay -nodisp -autoexit -loglevel quiet {SOUND}")
time.sleep(1) # avoid repeated alerts
time.sleep(0.5) # check interval
Everything *except* the bolded "-o" was written by ChatGPT (current default free tier). If you don't include the "-o" (for "overwrite"), each screen capture is written to a new file with a new filename, but the program only tests the *original* file for white pixels. So it only actually functions during the very first screen-check after you start the program, and each new check after that just re-does the first check over and over (while also piling up more and more screenshot files it isn't looking at).
You also have to figure out yourself (and manually edit) what the pixel coordinates should be for your particular usecase, but that's fair.
(Note: I haven't included the part where ChatGPT explains which prerequisites I should make sure I have installed in order to run this, but it did explain that and it does seem to have been correct.)
---
This may all have sounded like faint praise, but as someone who has barely used LLMs other than Whisper, I am genuinely very impressed by how close it got.
Nullius in verba, sure, but that's true of Stack Exchange too.
Rather than digging around trying (and failing, other than the Windows program) to find someone who has posted *almost* what you were looking for so that you can tinker with it until it does *exactly* what you were looking for, you can directly ask an Internet egregore to manifest the software that post *would* contain if it existed!
The future is *wild*.