MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / captureWindow

Function captureWindow

src/utils/computerUse/platforms/linux.ts:199–221  ·  view source on GitHub ↗
(hwnd)

Source from the content-addressed store, hash-verified

197 },
198
199 async captureWindow(hwnd) {
200 try {
201 // Use xdotool to get window geometry, then import (ImageMagick) to capture
202 if (commandExists('import')) {
203 const jpgPath = '/tmp/cu-window-capture.jpg'
204 await runAsync(['import', '-window', hwnd, '-quality', '75', jpgPath])
205
206 // Get dimensions from xdotool
207 const geom = run(['xdotool', 'getwindowgeometry', '--shell', hwnd])
208 const wMatch = geom.match(/WIDTH=(\d+)/)
209 const hMatch = geom.match(/HEIGHT=(\d+)/)
210 const width = wMatch ? Number(wMatch[1]) : 0
211 const height = hMatch ? Number(hMatch[1]) : 0
212
213 const file = Bun.file(jpgPath)
214 const buffer = await file.arrayBuffer()
215 return { base64: Buffer.from(buffer).toString('base64'), width, height }
216 }
217 return null
218 } catch {
219 return null
220 }
221 },
222}
223
224// ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 4

commandExistsFunction · 0.85
runAsyncFunction · 0.85
runFunction · 0.70
toStringMethod · 0.65

Tested by

no test coverage detected