# Sandbox desktop
URL: https://docs.munito.ai/sandboxes/desktop

The `desktop` template is the [`ubuntu` template](https://docs.munito.ai/sandboxes/templates) with an Xfce desktop and Firefox. The sandbox streams its desktop to a browser on port 6080.

## Open a desktop [#open-a-desktop]

1. Create a sandbox from the `desktop` template:

```bash
curl -sS --fail-with-body https://api.munito.ai/sandboxes/v1/sandboxes \
  -H "Authorization: Bearer $MUNITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template": "desktop"}'
```

2. Get a signed URL of port 6080:

```bash
curl -sS --fail-with-body -X POST "https://api.munito.ai/sandboxes/v1/sandboxes/$SANDBOX/ports/6080/url" \
  -H "Authorization: Bearer $MUNITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expires_in": 3600}'
```

3. Open the `url` in a browser. Use the keyboard and the mouse as on your own computer.

- A desktop needs 2 vCPUs and 4 GiB at least. A create without `size` gets the `default` size, and the API refuses `small`.
- A desktop starts in less than one second, as the other templates do.
- The viewer fits the screen to your browser window.
- Port 6080 is private. A person with the signed URL can see and control the desktop until the URL ends. See [ports and SSH](https://docs.munito.ai/sandboxes/ports-and-ssh).

## Control a desktop from an agent [#control-a-desktop-from-an-agent]

An agent controls the desktop with commands. Send each command to `POST /sandboxes/{sandbox_id}/exec`. The commands find the screen at once:

| Task                     | Command                                                                                           |
| ------------------------ | ------------------------------------------------------------------------------------------------- |
| Take a screenshot        | `scrot -o /tmp/screen.png`, then `GET /sandboxes/{sandbox_id}/files/content?path=/tmp/screen.png` |
| Move the mouse and click | `xdotool mousemove 640 400 click 1`                                                               |
| Type text                | `xdotool type 'hello'`                                                                            |
| Press keys               | `xdotool key ctrl+l`                                                                              |
| Open a page              | `nohup firefox https://example.com >/dev/null 2>&1 &`                                             |

- For screenshots of one size, set the size of the screen: `munito-desktop size 1280x800`. The viewer then keeps this size. `munito-desktop size auto` lets the viewer fit the screen to its window again.
- To change the frame rate of the stream, use `munito-desktop fps 60`. The frame rate is from 8 to 60, and the default is 30. A higher frame rate uses more of the sandbox's vCPUs.

## Price [#price]

A desktop adds $0.10 for each hour that it runs, on any size. A `default` desktop pays $0.118 an hour: $0.018 for its size and $0.10 for the desktop. See [pricing and limits](https://docs.munito.ai/sandboxes/pricing).

- The stream sends only the parts of the screen that change. A still screen uses almost no CPU.
