Skip to main content

pt-web-vnc

Serve a display or the window of a particular application via VNC & http using x11vnc & novnc.

The script can share an existing display or create a new one, depending on the provided display id. New displays are created using Xvfb and it’s dimensions and color depth can be specified via command line arguments.

It’s also possible to share particular windows from a display by using the ‘window-title’ argument. This will look for a window with the provided name in a given display and will only share that particular section of the display. If this argument is not provided, the whole display is shared.

A python module pt_web_vnc is also included which provides synchronous and asynchronous wrappers around the pt-web-vnc script.

Usage

pt-web-vnc <COMMAND> --display-id <DISPLAY_ID> --HEIGHT <SCREEN_HEIGHT> --WIDTH <SCREEN_WIDTH> --ssl-certificate <SSL_CERTIFICATE> --window-title <WINDOW_TITLE> --run <RUN_COMMAND> --background-colour <COLOUR> --with-window-manager

where:
  COMMAND: {start, stop, url, clients}
    start: start sharing a display or app based on the given arguments.
    stop: stop sharing the given display.
    url: print the novnc URL where the provided display is being served.
    clients: print the number of clients connected to a particular display.
  --display-id DISPLAY_ID: integer, id for the display to use/create. If the provided display ID doesn\'t exist, a new one will be created.
  --height SCREEN_HEIGHT: integer, height in pixels for the virtual display to create. Defaults to 1080.
  --width SCREEN_WIDTH: integer, width in pixels for the virtual display to create. Defaults to 1920.
  --depth SCREEN_DEPTH: integer, pixel depth for the virtual display to create. Defaults to 24.
  --ssl-certificate SSL_CERTIFICATE: path to combined SSL certificate & key file. Optional.
  --window-title WINDOW_TITLE: Title of a window in a display to share over VNC. Optional.
  --run RUN_COMMAND: Command to run before starting VNC server.
  --background-colour COLOUR: string with a colour name to use as background for the virtual display.
  --with-window-manager: start a window manager in the specified DISPLAY_ID. For now, the window manager used is 'bspwm'.

Examples

Start a virtual display with custom dimensions and background

$ pt-web-vnc start --display-id 100 --height 500 --width 1000 --background-colour red
# Get the URL to connect
$ pt-web-vnc url --display-id 100
http://pi-top.local:61100/vnc.html?autoconnect=true
$ pt-web-vnc stop --display-id 100

Run an application in a virtual display and share its window

By using the --run argument to start an application and providing its window title via --window-title it’s possible to share a particular window.

# Start chromium and look for its window title
$ pt-web-vnc start --display-id 50 --run 'chromium-browser' --window-title 'New Tab - Chromium'
# Get the URL to connect
$ pt-web-vnc url --display-id 50
http://pi-top.local:61050/vnc.html?autoconnect=true
$ pt-web-vnc stop --display-id 50

Share an existing display

It’s possible to share your main display instead of creating a new one by providing its display id. In most cases, the id for your main display will be 0.

$ pt-web-vnc start --display-id 0
# Get the URL to connect
$ pt-web-vnc url --display-id 0
http://pi-top.local:61000/vnc.html?autoconnect=true
$ pt-web-vnc stop --display-id 000

Python module examples

Create and share a display with custom dimensions and background colour

>>> from pt_web_vnc import start, connection_details, stop
>>> start(
      display_id=50,
      height=500,
      width=1000,
      background_colour="blue",
)
>>> # Get connection details
>>> details = connection_details(display_id=50)
>>> details.url
'http://pi-top.local:61050/vnc.html?autoconnect=true&resize=scale'

>>> # Stop sharing
>>> stop(display_id=50)

Asynchronously start sharing display 0

>>> import asyncio
>>> from pt_web_vnc import async_start, async_connection_details, async_stop
>>> # Start sharing display 0
>>> asyncio.run(async_start(display_id=0)
...
>>> # Get connection details
>>> details = asyncio.run(async_connection_details(display_id=0))
>>> details.url
'http://pi-top.local:61000/vnc.html?autoconnect=true&resize=scale'
>>> # Returned object also contains parsed elements of the URL
>>> details.scheme
'http'
>>> details.hostname
'pi-top.local'
>>> details.port
61000
>>> details.path
'/vnc.html?autoconnect=true&resize=scale'
>>> # Stop sharing display 0
>>> asyncio.run(async_stop(display_id=0)

Metadata

Release files for pt-web-vnc 0.5.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pt-web-vnc 0.5.0.post1
File Size Uploaded Provenance Actions
pt-web-vnc-0.5.0.post1.tar.gz 9.3 kB Without provenance Details for pt-web-vnc-0.5.0.post1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pt-web-vnc 0.5.0.post1
File Interpreter ABI Platform Actions
pt_web_vnc-0.5.0.post1-py2.py3-none-any.whl Python 2, Python 3 none any Details for pt_web_vnc-0.5.0.post1-py2.py3-none-any.whl

Total release size: 23.0 kB

Release files / pt-web-vnc-0.5.0.post1.tar.gz

Download URL pt-web-vnc-0.5.0.post1.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b784395ba587048e6dec1d575b9472e539fe6db36315a81f0ea23e8a0f01afd5
BLAKE2b-256 checksum
How to use checksums
fed6a55936913a85ef2bdbd06c5410bd4118779f9da96a51dacdf11d8e101ae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release files / pt_web_vnc-0.5.0.post1-py2.py3-none-any.whl

Download URL pt_web_vnc-0.5.0.post1-py2.py3-none-any.whl
Size 13.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cfc049fba9a860f4715d256ab8688f0e23c23ca36ff89f280697dbbad5a086d6
BLAKE2b-256 checksum
How to use checksums
69371dbc920418a8f07651d156aec5c90c58fd6de3589d086daf2498fec94a00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Security for pt-web-vnc 0.5.0.post1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page