* Get the current screen size. * @returns An ScreenSize object * @throws Error if screen size cannot be determined
()
| 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. |
no outgoing calls
no test coverage detected