MCPcopy Create free account
hub / github.com/e2b-dev/desktop / getScreenSize

Method getScreenSize

packages/js-sdk/src/sandbox.ts:385–401  ·  view source on GitHub ↗

* Get the current screen size. * @returns An ScreenSize object * @throws Error if screen size cannot be determined

()

Source from the content-addressed store, hash-verified

383 * @throws Error if screen size cannot be determined
384 */
385 async getScreenSize(): Promise<ScreenSize> {
386 const result = await this.commands.run('xrandr')
387
388 const match = result.stdout.match(/(\d+x\d+)/)
389 if (!match) {
390 throw new Error(
391 `Failed to parse screen size from output: ${result.stdout}`
392 )
393 }
394
395 try {
396 const [width, height] = match[1].split('x').map((val) => parseInt(val))
397 return { width, height }
398 } catch (error) {
399 throw new Error(`Invalid screen size format: ${match[1]}`)
400 }
401 }
402
403 /**
404 * Write the given text at the current cursor position.

Callers 3

screen.test.tsFile · 0.80
mouse.test.tsFile · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected