(hwnd)
| 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 | // --------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected