برومبت إنجليزي: تطبيق macOS يعيد تحجيم سطح المكتب حول البكسلات الميتة
Instead of replacing a MacBook screen with a strip of dead pixels, have an AI coding agent build a native macOS app that shows the whole desktop on the healthy area only and survives restarts.
- 17 مشاهدة
- 5 نسخة
- 0 إعجاب
- 0 تفضيل
الأمر
You are an expert macOS engineer fluent in Swift, CoreGraphics (including private APIs), the Accessibility API and launchd. You are working as a coding agent with permission to run commands directly on my machine.
THE PROBLEM
My Mac's built-in screen has a strip of dead pixels. Instead of replacing the screen, build me a small native macOS app that makes the entire desktop (menu bar, Dock, windows, cursor) appear only on the healthy part of the screen, rescaled to fit, not just cropped. It must survive restarts.
MY INPUTS (edit before sending)
- App name: [e.g. DeadZone]
- Dead strip edge: [LEFT / RIGHT / TOP / BOTTOM]
- Approximate strip size: [e.g. 3/32 of the screen width, or a number of points]
- Emergency hotkey: [e.g. Control+Option+Command+R]
- Extra notes about my setup (optional): [Mac model, external monitors, etc.]
BEFORE WRITING CODE: CHECK MY MACHINE
- macOS version.
- Built-in screen resolution and Retina scale.
- Whether a Swift compiler is available (use the Xcode Command Line Tools if Xcode is missing).
Build the app as a single Swift file compiled with swiftc. No Xcode project.
HOW IT SHOULD WORK (Rescale mode, the default)
- Create a virtual display with the private CGVirtualDisplay API (declare CGVirtualDisplay, CGVirtualDisplayDescriptor, CGVirtualDisplaySettings and CGVirtualDisplayMode in a bridging header). Size it to the healthy area: the full panel minus the dead strip along the chosen edge.
- Make the virtual display the main display (origin 0,0) with CGConfigureDisplayOrigin and kCGConfigureForAppOnly, so everything reverts automatically when the app quits.
- Place the physical built-in panel in the display arrangement on the side opposite where external monitors go, so external monitors stay reachable (e.g. strip on the left: physical panel to the LEFT of the virtual display, externals to the right).
- Stream the virtual display live with CGDisplayStream (cursor included, 60 fps) into a borderless, click-through window at shielding level that covers the physical panel: the dead strip stays black and the stream fills the healthy area.
- Keep the cursor off the physical panel: if it ever lands there, warp it back onto the virtual display.
- Using the Accessibility API, move any window left on the physical panel onto the virtual display.
RESOLUTIONS
- Offer Retina "looks like" resolutions similar to macOS's own options for my panel, with the other dimension matched to the healthy area's aspect ratio.
- Important: give CGVirtualDisplayMode the POINT sizes with hiDPI = 1. If you pass pixel sizes, macOS doubles them and everything becomes tiny.
- After switching modes, pick the HiDPI mode where pixelWidth = 2 × width, fall back to the closest match, and restart the stream at the new pixel size.
USER INTERFACE
- A menu-bar item only (no Dock icon, LSUIElement) with: Adjust Dead Area…, a Resolution submenu, Switch Mode, Restart, Quit.
- A small settings window with: a Rescale / Block-strip mode switch, a resolution pop-up, a slider plus −1/+1 buttons for the dead-strip size in points (show the percentage of the screen), Reset to default, and Done.
- While the settings window is open, paint the dead strip RED so I can line it up exactly with the dead pixels; apply size changes after the slider settles.
- Save all settings in UserDefaults.
- A fallback "Block strip" mode: paint the strip black, keep the cursor out of it, and push windows out of it. Use it automatically whenever rescaling isn't possible.
- An emergency hotkey to toggle between the two modes.
RELIABILITY (handle these from the start)
- The lock screen cannot be screen-captured. On screen sleep, system sleep, lock (com.apple.screenIsLocked) or a session switch, tear down the virtual display so the real lock screen shows. Bring it back about 1.5 s after unlock or wake. Otherwise the user wakes up to a blank screen.
- If the stream reports .stopped, rebuild it. Ignore callbacks from streams you have already replaced (use a generation counter).
- If no frame arrives within 5 seconds, fall back to Block-strip mode and explain why in an alert.
- If the panel goes offline (lid closed with an external display) or is mirrored, pause rescaling; resume when it comes back.
- When a new external display appears, place it on the correct side of the virtual display.
- Allow only one running instance (terminate older copies on launch), and exit immediately on SIGTERM even if an alert is open.
PERMISSIONS, SIGNING AND STARTUP
- The app needs Screen Recording (CGPreflightScreenCaptureAccess / CGRequestScreenCaptureAccess) and Accessibility. Explain clearly how to grant both.
- Ad-hoc signing makes macOS forget these permissions on every rebuild. Provide a one-time setup-signing.sh that creates a self-signed code-signing certificate in my login keychain, and make install.sh sign with it whenever it exists. Let me run that script myself.
- install.sh: compile, build the .app bundle in ~/Applications, sign it, and install a LaunchAgent (RunAtLoad; KeepAlive only on a non-successful exit) so it starts at every login. Also provide uninstall.sh.
WORKING STYLE
- Test each piece on my machine before moving on: list the virtual display's modes, verify the arrangement and the current mode, and diagnose problems from system logs (pmset, launchctl) instead of guessing.
- Tell me plainly what you could not test.
- Ask before anything sensitive, such as keychain changes or permissions.
DELIVERABLES
- Machine check report (macOS version, resolution, scale, compiler).
- One complete Swift file plus the bridging header.
- Scripts: setup-signing.sh, install.sh, uninstall.sh.
- Step-by-step instructions for granting permissions.
- Test results from my machine and an explicit list of anything left untested.
You are an expert macOS engineer fluent in Swift, CoreGraphics (including private APIs), the Accessibility API and launchd. You are working as a coding agent with permission to run commands directly on my machine. ## THE PROBLEM My Mac's built-in screen has a strip of dead pixels. Instead of replacing the screen, build me a small native macOS app that makes the entire desktop (menu bar, Dock, windows, cursor) appear only on the healthy part of the screen, rescaled to fit, not just cropped. It must survive restarts. ## MY INPUTS (edit before sending) - App name: [e.g. DeadZone] - Dead strip edge: [LEFT / RIGHT / TOP / BOTTOM] - Approximate strip size: [e.g. 3/32 of the screen width, or a number of points] - Emergency hotkey: [e.g. Control+Option+Command+R] - Extra notes about my setup (optional): [Mac model, external monitors, etc.] ## BEFORE WRITING CODE: CHECK MY MACHINE 1. macOS version. 2. Built-in screen resolution and Retina scale. 3. Whether a Swift compiler is available (use the Xcode Command Line Tools if Xcode is missing). Build the app as a single Swift file compiled with swiftc. No Xcode project. ## HOW IT SHOULD WORK (Rescale mode, the default) 1. Create a virtual display with the private CGVirtualDisplay API (declare CGVirtualDisplay, CGVirtualDisplayDescriptor, CGVirtualDisplaySettings and CGVirtualDisplayMode in a bridging header). Size it to the healthy area: the full panel minus the dead strip along the chosen edge. 2. Make the virtual display the main display (origin 0,0) with CGConfigureDisplayOrigin and kCGConfigureForAppOnly, so everything reverts automatically when the app quits. 3. Place the physical built-in panel in the display arrangement on the side opposite where external monitors go, so external monitors stay reachable (e.g. strip on the left: physical panel to the LEFT of the virtual display, externals to the right). 4. Stream the virtual display live with CGDisplayStream (cursor included, 60 fps) into a borderless, click-through window at shielding level that covers the physical panel: the dead strip stays black and the stream fills the healthy area. 5. Keep the cursor off the physical panel: if it ever lands there, warp it back onto the virtual display. 6. Using the Accessibility API, move any window left on the physical panel onto the virtual display. ## RESOLUTIONS - Offer Retina "looks like" resolutions similar to macOS's own options for my panel, with the other dimension matched to the healthy area's aspect ratio. - Important: give CGVirtualDisplayMode the POINT sizes with hiDPI = 1. If you pass pixel sizes, macOS doubles them and everything becomes tiny. - After switching modes, pick the HiDPI mode where pixelWidth = 2 × width, fall back to the closest match, and restart the stream at the new pixel size. ## USER INTERFACE - A menu-bar item only (no Dock icon, LSUIElement) with: Adjust Dead Area…, a Resolution submenu, Switch Mode, Restart, Quit. - A small settings window with: a Rescale / Block-strip mode switch, a resolution pop-up, a slider plus −1/+1 buttons for the dead-strip size in points (show the percentage of the screen), Reset to default, and Done. - While the settings window is open, paint the dead strip RED so I can line it up exactly with the dead pixels; apply size changes after the slider settles. - Save all settings in UserDefaults. - A fallback "Block strip" mode: paint the strip black, keep the cursor out of it, and push windows out of it. Use it automatically whenever rescaling isn't possible. - An emergency hotkey to toggle between the two modes. ## RELIABILITY (handle these from the start) - The lock screen cannot be screen-captured. On screen sleep, system sleep, lock (com.apple.screenIsLocked) or a session switch, tear down the virtual display so the real lock screen shows. Bring it back about 1.5 s after unlock or wake. Otherwise the user wakes up to a blank screen. - If the stream reports .stopped, rebuild it. Ignore callbacks from streams you have already replaced (use a generation counter). - If no frame arrives within 5 seconds, fall back to Block-strip mode and explain why in an alert. - If the panel goes offline (lid closed with an external display) or is mirrored, pause rescaling; resume when it comes back. - When a new external display appears, place it on the correct side of the virtual display. - Allow only one running instance (terminate older copies on launch), and exit immediately on SIGTERM even if an alert is open. ## PERMISSIONS, SIGNING AND STARTUP - The app needs Screen Recording (CGPreflightScreenCaptureAccess / CGRequestScreenCaptureAccess) and Accessibility. Explain clearly how to grant both. - Ad-hoc signing makes macOS forget these permissions on every rebuild. Provide a one-time setup-signing.sh that creates a self-signed code-signing certificate in my login keychain, and make install.sh sign with it whenever it exists. Let me run that script myself. - install.sh: compile, build the .app bundle in ~/Applications, sign it, and install a LaunchAgent (RunAtLoad; KeepAlive only on a non-successful exit) so it starts at every login. Also provide uninstall.sh. ## WORKING STYLE - Test each piece on my machine before moving on: list the virtual display's modes, verify the arrangement and the current mode, and diagnose problems from system logs (pmset, launchctl) instead of guessing. - Tell me plainly what you could not test. - Ask before anything sensitive, such as keychain changes or permissions. ## DELIVERABLES 1. Machine check report (macOS version, resolution, scale, compiler). 2. One complete Swift file plus the bridging header. 3. Scripts: setup-signing.sh, install.sh, uninstall.sh. 4. Step-by-step instructions for granting permissions. 5. Test results from my machine and an explicit list of anything left untested.
زر النسخ ينسخ الأمر بصيغته الأصلية (Markdown)، جاهزاً للصق في أداة الذكاء الاصطناعي.
كيفية الاستخدام
1) Run this prompt in a coding agent that can execute commands on your Mac (Claude Code, Codex, Gemini CLI), not in a regular chat: it needs to inspect your machine, compile and test. 2) Fill in the MY INPUTS section: app name, which edge the dead strip is on, its approximate size, and the emergency hotkey. 3) To estimate the strip size, open a full-screen white image and measure the strip against the screen; fine-tune it later in the app's settings window, where the strip is painted red. 4) Approve the Screen Recording and Accessibility requests, and run the signing script yourself once so permissions survive rebuilds. 5) Remember the emergency hotkey: if streaming ever fails, it switches you straight to Block-strip mode. Note: the app relies on Apple's undocumented CGVirtualDisplay API, so major macOS updates may require adjustments.
التفاصيل
Instead of replacing a MacBook screen with a strip of dead pixels, have an AI coding agent build a native macOS app that shows the whole desktop on the healthy area only and survives restarts.
أوامر مشابهة
التعليقات
سجّل الدخول لتشارك رأيك أو تسأل عن هذا الأمر.
لا توجد تعليقات بعد
كن أول من يعلّق ويشارك تجربته مع هذا الأمر.